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 {
         //Todo: use taxonomy path instead of the slug
         $query->field('taxonomies.slug')->equals(strtolower($specification->getTaxonomyNodeName()));
     }
 }
 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();
     }
 }