public function visitBrand(SpecificationInterface $specification, SpecificationWalker $walker, $query)
 {
     $id = $specification->getBrand()->getId();
     $brand = $specification->getBrand();
     $query->field('brands')->includesReferenceTo($brand);
     //        $query->field('brand.id')->equals(new \MongoId($id));
 }
 public function visitTaxonomyNode(SpecificationInterface $specification, SpecificationWalker $walker, $query)
 {
     $taxonomyNode = $specification->getTaxonomyNode();
     //Do we already have the taxonomy node?
     if (null != $taxonomyNode) {
         $query->from($taxonomyNode);
         //If not we need to describe the taxonomy node
     } else {
         $query->field('taxonomies.name')->equals($specification->getName());
     }
 }
Пример #3
0
 protected function executeSpecification(SpecificationInterface $specification, $matchOne = false)
 {
     $results = array();
     foreach ($this->products as $product) {
         if (!$specification->isSatisfiedBy($product)) {
             continue;
         }
         if ($matchOne) {
             return $product;
         }
         $results[] = $product;
     }
     return $results;
 }
 public function visitTaxonomyNode(SpecificationInterface $specification, SpecificationWalker $walker, $query)
 {
     $taxonomyNode = $specification->getTaxonomyNode();
     //Do we already have the taxonomy node?
     if (null != $taxonomyNode) {
         // $query->field('taxonomies')->equals($taxonomyNode);
         //If not we need to describe the taxonomy node
     } else {
         $rootAlias = $query->getRootAlias();
         $query->innerJoin($rootAlias . '.taxonomies', 't');
         $parameterId = $this->generateParameterId();
         $query->andWhere('t.name =?' . $parameterId);
         $query->setParameter($parameterId, $specification->getTaxonomyNodeName());
     }
 }
 protected function executeSpecification(SpecificationInterface $specification, $matchOne = false)
 {
     $repo = $this->dm->getRepository($this->taxonomyNodeClass);
     //Todo: add a specification walker
     //$this->getSpecificationWalker()->walk($specification, $queryBuilder);
     $queryBuilder = $repo->getChildrenQueryBuilder(null);
     //Construct a materialized child query for the current taxonomy node (each root node of the collection is a different taxonomy)
     $queryBuilder->field('path')->equals(new \MongoRegex(preg_quote($specification->getTaxonomyNodeName()) . '.+/'))->field('level')->gt(1);
     //Level = taxonomy name
     $query = $queryBuilder->getQuery();
     if ($matchOne) {
         return $query->getSingleResult();
     } else {
         return $query->execute();
     }
 }
 public function visitHydration(SpecificationInterface $specification, SpecificationWalker $walker, $query)
 {
     $query->hydrate($specification->getValue());
 }