vendor/jackalope/jackalope/src/Jackalope/Query/QOM/QueryObjectModelFactory.php line 232

Open in your IDE?
  1. <?php
  2. namespace Jackalope\Query\QOM;
  3. use InvalidArgumentException;
  4. use Jackalope\ObjectManager;
  5. use Jackalope\FactoryInterface;
  6. use PHPCR\Query\QOM\QueryObjectModelConstantsInterface;
  7. use PHPCR\Query\QOM\QueryObjectModelFactoryInterface;
  8. use PHPCR\Query\QOM\SourceInterface;
  9. use PHPCR\Query\QOM\ConstraintInterface;
  10. use PHPCR\Query\QOM\JoinConditionInterface;
  11. use PHPCR\Query\QOM\DynamicOperandInterface;
  12. use PHPCR\Query\QOM\StaticOperandInterface;
  13. use PHPCR\Query\QOM\PropertyValueInterface;
  14. /**
  15.  * {@inheritDoc}
  16.  *
  17.  * @license http://www.apache.org/licenses Apache License Version 2.0, January 2004
  18.  * @license http://opensource.org/licenses/MIT MIT License
  19.  *
  20.  * @api
  21.  */
  22. class QueryObjectModelFactory implements QueryObjectModelFactoryInterface
  23. {
  24.     /**
  25.      * The factory to instantiate objects
  26.      *
  27.      * @var FactoryInterface
  28.      */
  29.     protected $factory;
  30.     /**
  31.      * @var ObjectManager
  32.      */
  33.     protected $objectManager;
  34.     /**
  35.      * Create the query object model factory - get this from the QueryManager
  36.      *
  37.      * @param FactoryInterface $factory       the object factory
  38.      * @param ObjectManager    $objectManager only used to create the query (can
  39.      *      be omitted if you do not want to execute the query but just use it
  40.      *      with a parser)
  41.      */
  42.     public function __construct(FactoryInterface $factoryObjectManager $objectManager null)
  43.     {
  44.         $this->factory $factory;
  45.         $this->objectManager $objectManager;
  46.     }
  47.     /**
  48.      * {@inheritDoc}
  49.      *
  50.      * @api
  51.      */
  52.     public function createQuery(
  53.         SourceInterface $source,
  54.         ConstraintInterface $constraint null,
  55.         array $orderings = [],
  56.         array $columns = []
  57.     ) {
  58.         return $this->factory->get(
  59.             QueryObjectModel::class,
  60.             [$this->objectManager$source$constraint$orderings$columns]
  61.         );
  62.     }
  63.     // TODO: should we use the factory ->get here? but this would mean all of them need to expect the factory as first parameter
  64.     // or refactor the factory to make the first param optional.
  65.     /**
  66.      * {@inheritDoc}
  67.      *
  68.      * @api
  69.      */
  70.     public function selector($selectorName$nodeTypeName)
  71.     {
  72.         return new Selector($selectorName$nodeTypeName);
  73.     }
  74.     /**
  75.      * {@inheritDoc}
  76.      *
  77.      * @api
  78.      */
  79.     public function join(SourceInterface $leftSourceInterface $right$joinTypeJoinConditionInterface $joinCondition)
  80.     {
  81.         return new Join($left$right$joinType$joinCondition);
  82.     }
  83.     /**
  84.      * {@inheritDoc}
  85.      *
  86.      * @api
  87.      */
  88.     public function equiJoinCondition($selector1Name$property1Name$selector2Name$property2Name)
  89.     {
  90.         return new EquiJoinCondition($selector1Name$property1Name$selector2Name$property2Name);
  91.     }
  92.     /**
  93.      * {@inheritDoc}
  94.      *
  95.      * @api
  96.      */
  97.     public function sameNodeJoinCondition($selector1Name$selector2Name$selector2Path null)
  98.     {
  99.         return new SameNodeJoinCondition($selector1Name$selector2Name$selector2Path);
  100.     }
  101.     /**
  102.      * {@inheritDoc}
  103.      *
  104.      * @api
  105.      */
  106.     public function childNodeJoinCondition($childSelectorName$parentSelectorName)
  107.     {
  108.         return new ChildNodeJoinCondition($childSelectorName$parentSelectorName);
  109.     }
  110.     /**
  111.      * {@inheritDoc}
  112.      *
  113.      * @api
  114.      */
  115.     public function descendantNodeJoinCondition($descendantSelectorName$ancestorSelectorName)
  116.     {
  117.         return new DescendantNodeJoinCondition($descendantSelectorName$ancestorSelectorName);
  118.     }
  119.     /**
  120.      * {@inheritDoc}
  121.      *
  122.      * @api
  123.      */
  124.     public function andConstraint(ConstraintInterface $constraint1ConstraintInterface $constraint2)
  125.     {
  126.         return new AndConstraint($constraint1$constraint2);
  127.     }
  128.     /**
  129.      * {@inheritDoc}
  130.      *
  131.      * @api
  132.      */
  133.     public function orConstraint(ConstraintInterface $constraint1ConstraintInterface $constraint2)
  134.     {
  135.         return new OrConstraint($constraint1$constraint2);
  136.     }
  137.     /**
  138.      * {@inheritDoc}
  139.      *
  140.      * @api
  141.      */
  142.     public function notConstraint(ConstraintInterface $constraint)
  143.     {
  144.         return new NotConstraint($constraint);
  145.     }
  146.     /**
  147.      * {@inheritDoc}
  148.      *
  149.      * @api
  150.      */
  151.     public function comparison(DynamicOperandInterface $operand1$operatorStaticOperandInterface $operand2)
  152.     {
  153.         return new ComparisonConstraint($operand1$operator$operand2);
  154.     }
  155.     /**
  156.      * {@inheritDoc}
  157.      *
  158.      * @api
  159.      */
  160.     public function propertyExistence($selectorName$propertyName)
  161.     {
  162.         return new PropertyExistence($selectorName$propertyName);
  163.     }
  164.     /**
  165.      * {@inheritDoc}
  166.      *
  167.      * @throws InvalidArgumentException
  168.      *
  169.      * @api
  170.      */
  171.     public function fullTextSearch($selectorName$propertyName$fullTextSearchExpression)
  172.     {
  173.         return new FullTextSearchConstraint($selectorName$propertyName$fullTextSearchExpression);
  174.     }
  175.     /**
  176.      * {@inheritDoc}
  177.      *
  178.      * @api
  179.      */
  180.     public function sameNode($selectorName$path)
  181.     {
  182.         return new SameNode($selectorName$path);
  183.     }
  184.     /**
  185.      * {@inheritDoc}
  186.      *
  187.      * @api
  188.      */
  189.     public function childNode($selectorName$path)
  190.     {
  191.         return new ChildNodeConstraint($selectorName$path);
  192.     }
  193.     /**
  194.      * {@inheritDoc}
  195.      *
  196.      * @api
  197.      */
  198.     public function descendantNode($selectorName$path)
  199.     {
  200.         return new DescendantNodeConstraint($selectorName$path);
  201.     }
  202.     /**
  203.      * {@inheritDoc}
  204.      *
  205.      * @throws InvalidArgumentException
  206.      *
  207.      * @api
  208.      */
  209.     public function propertyValue($selectorName$propertyName)
  210.     {
  211.         return new PropertyValue($selectorName$propertyName);
  212.     }
  213.     /**
  214.      * {@inheritDoc}
  215.      *
  216.      * @api
  217.      */
  218.     public function length(PropertyValueInterface $propertyValue)
  219.     {
  220.         return new Length($propertyValue);
  221.     }
  222.     /**
  223.      * {@inheritDoc}
  224.      *
  225.      * @throws InvalidArgumentException
  226.      *
  227.      * @api
  228.      */
  229.     public function nodeName($selectorName)
  230.     {
  231.         return new NodeName($selectorName);
  232.     }
  233.     /**
  234.      * {@inheritDoc}
  235.      *
  236.      * @api
  237.      */
  238.     public function nodeLocalName($selectorName)
  239.     {
  240.         return new NodeLocalName($selectorName);
  241.     }
  242.     /**
  243.      * {@inheritDoc}
  244.      *
  245.      * @throws InvalidArgumentException
  246.      *
  247.      * @api
  248.      */
  249.     public function fullTextSearchScore($selectorName)
  250.     {
  251.         return new FullTextSearchScore($selectorName);
  252.     }
  253.     /**
  254.      * {@inheritDoc}
  255.      *
  256.      * @api
  257.      */
  258.     public function lowerCase(DynamicOperandInterface $operand)
  259.     {
  260.         return new LowerCase($operand);
  261.     }
  262.     /**
  263.      * {@inheritDoc}
  264.      *
  265.      * @api
  266.      */
  267.     public function upperCase(DynamicOperandInterface $operand)
  268.     {
  269.         return new UpperCase($operand);
  270.     }
  271.     /**
  272.      * {@inheritDoc}
  273.      *
  274.      * @api
  275.      */
  276.     public function bindVariable($bindVariableName)
  277.     {
  278.         return new BindVariableValue($bindVariableName);
  279.     }
  280.     /**
  281.      * {@inheritDoc}
  282.      *
  283.      * @api
  284.      */
  285.     public function literal($literalValue)
  286.     {
  287.         return new Literal($literalValue);
  288.     }
  289.     /**
  290.      * {@inheritDoc}
  291.      *
  292.      * @api
  293.      */
  294.     public function ascending(DynamicOperandInterface $operand)
  295.     {
  296.         return new Ordering($operandQueryObjectModelConstantsInterface::JCR_ORDER_ASCENDING);
  297.     }
  298.     /**
  299.      * {@inheritDoc}
  300.      *
  301.      * @api
  302.      */
  303.     public function descending(DynamicOperandInterface $operand)
  304.     {
  305.         return new Ordering($operandQueryObjectModelConstantsInterface::JCR_ORDER_DESCENDING);
  306.     }
  307.     /**
  308.      * {@inheritDoc}
  309.      *
  310.      * @throws \InvalidArgumentException
  311.      *
  312.      * @api
  313.      */
  314.     public function column($selectorName$propertyName null$columnName null)
  315.     {
  316.         return new Column($selectorName$propertyName$columnName);
  317.     }
  318. }