Exemple #1
0
 function it_also_sets_name_on_the_root_taxon(TaxonInterface $taxon)
 {
     $taxon->setName('Category')->shouldBeCalled();
     $taxon->setTaxonomy($this)->shouldBeCalled();
     $this->setRoot($taxon);
     $this->setName('Category');
 }
 /**
  * {@inheritdoc}
  */
 public function findChildren(TaxonInterface $taxon)
 {
     $root = $taxon->isRoot() ? $taxon : $taxon->getRoot();
     $queryBuilder = $this->createQueryBuilder('o');
     $queryBuilder->andWhere($queryBuilder->expr()->eq('o.root', ':root'))->andWhere($queryBuilder->expr()->lt('o.right', ':right'))->andWhere($queryBuilder->expr()->gt('o.left', ':left'))->setParameter('root', $root)->setParameter('left', $taxon->getLeft())->setParameter('right', $taxon->getRight());
     return $queryBuilder->getQuery()->getResult();
 }
 /**
  * @param TaxonInterface $taxon
  *
  * @return callable|null
  */
 private function getFilterTaxonOption(TaxonInterface $taxon)
 {
     if (null === $taxon->getId()) {
         return null;
     }
     return function (TaxonInterface $entry) use($taxon) {
         return $entry->getId() !== $taxon->getId();
     };
 }
 /**
  * Get the closure to filter taxon collection.
  *
  * @param TaxonInterface $taxon
  *
  * @return callable|null
  */
 private function getFilterTaxonOption(TaxonInterface $taxon)
 {
     $closure = null;
     if (null !== $taxon->getId()) {
         $closure = function ($entry) use($taxon) {
             return $entry->getId() != $taxon->getId();
         };
     }
     return $closure;
 }
 /**
  * {@inheritdoc}
  */
 public function selectMainTaxon(TaxonInterface $taxon)
 {
     $this->openTaxonBookmarks();
     Assert::isInstanceOf($this->getDriver(), Selenium2Driver::class);
     $this->getDriver()->executeScript(sprintf('$(\'input.search\').val(\'%s\')', $taxon->getName()));
     $this->getElement('search')->click();
     $this->getElement('search')->waitFor(10, function () {
         return $this->hasElement('search_item_selected');
     });
     $itemSelected = $this->getElement('search_item_selected');
     $itemSelected->click();
 }
Exemple #6
0
 function it_can_get_taxons_from_specific_taxonomy(TaxonInterface $taxon1, TaxonInterface $taxon2, TaxonInterface $taxon3, TaxonomyInterface $taxonomy1, TaxonomyInterface $taxonomy2)
 {
     $taxon1->getTaxonomy()->willReturn($taxonomy1);
     $taxon2->getTaxonomy()->willReturn($taxonomy1);
     $taxon3->getTaxonomy()->willReturn($taxonomy2);
     $taxonomy1->getName()->willReturn('Category');
     $taxonomy2->getName()->willReturn('Brand');
     $this->addTaxon($taxon1);
     $this->addTaxon($taxon2);
     $this->addTaxon($taxon3);
     $this->getTaxons('category')->shouldHaveCount(2);
     $this->getTaxons('brand')->shouldHaveCount(1);
 }
Exemple #7
0
 /**
  * {@inheritdoc}
  */
 public function addTranslation(TranslationInterface $translation)
 {
     parent::addTranslation($translation);
     if ($translation instanceof TaxonomyTranslation) {
         $this->root->setName($translation->getName());
     }
 }
Exemple #8
0
 /**
  * {@inheritdoc}
  */
 public function getPermalink()
 {
     if (null !== $this->permalink) {
         return $this->permalink;
     }
     if (null === $this->parent) {
         return $this->slug;
     }
     return $this->permalink = $this->parent->getPermalink() . '/' . $this->slug;
 }
Exemple #9
0
 /**
  * {@inheritdoc}
  */
 public function getPermalink()
 {
     $permalink = $this->translate()->getPermalink();
     if (null !== $permalink) {
         return $permalink;
     }
     if (null === $this->parent) {
         return $this->getSlug();
     }
     $this->setPermalink($permalink = $this->parent->getPermalink() . '/' . $this->getSlug());
     return $permalink;
 }
Exemple #10
0
 function it_allows_to_remove_child_taxons(TaxonomyInterface $taxonomy, TaxonInterface $taxon)
 {
     $this->setTaxonomy($taxonomy);
     $taxon->setTaxonomy($taxonomy)->shouldBeCalled();
     $taxon->setParent($this)->shouldBeCalled();
     $this->addChild($taxon);
     $taxon->setTaxonomy(null)->shouldBeCalled();
     $taxon->setParent(null)->shouldBeCalled();
     $this->removeChild($taxon);
 }
Exemple #11
0
 /**
  * {@inheritdoc}
  */
 public function removeTaxon(TaxonInterface $taxon)
 {
     $this->root->removeChild($taxon);
     return $this;
 }
Exemple #12
0
 /**
  * {@inheritdoc}
  */
 public function setParent(TaxonInterface $parent = null)
 {
     $this->parent = $parent;
     if (null !== $parent) {
         $parent->addChild($this);
     }
 }
 function it_does_reverse_transform_array_of_arrays_value(TaxonInterface $entityThree, TaxonInterface $entityFour)
 {
     $entityThree->getId()->willReturn(3);
     $entityFour->getId()->willReturn(4);
     $this->reverseTransform(array(array($entityThree, $entityFour)))->shouldHaveCount(2);
 }
 protected function createTaxonomiesMenuNode(ItemInterface $menu, TaxonInterface $taxon)
 {
     foreach ($taxon->getChildren() as $child) {
         $childMenu = $menu->addChild($child->getName(), array('route' => $child, 'labelAttributes' => array('icon' => 'icon-angle-right')));
         if ($child->getPath()) {
             $childMenu->setLabelAttribute('data-image', $child->getPath());
         }
         $this->createTaxonomiesMenuNode($childMenu, $child);
     }
 }
Exemple #15
0
 function it_allows_to_remove_child_taxons(TaxonInterface $taxon)
 {
     $taxon->getParent()->willReturn(null);
     $taxon->setParent($this)->shouldBeCalled();
     $this->addChild($taxon);
     $taxon->setParent(null)->shouldBeCalled();
     $this->removeChild($taxon);
 }
Exemple #16
0
 function it_also_sets_translation_on_root_taxon(TaxonInterface $taxon, TaxonomyTranslation $translation)
 {
     $translation->getName()->willReturn('New');
     $translation->getLocale()->shouldBeCalled();
     $translation->setTranslatable($this)->shouldBeCalled();
     $taxon->setName('New')->shouldBeCalled();
     $taxon->setTaxonomy($this)->shouldBeCalled();
     $taxon->setCurrentLocale(Argument::any())->shouldBeCalled();
     $taxon->setFallbackLocale(Argument::any())->shouldBeCalled();
     $this->setRoot($taxon);
     $this->addTranslation($translation);
 }
 /**
  * @When /^I am browsing products from ("([^"]+)" taxon)$/
  */
 public function iAmBrowsingProductsFromTaxon(TaxonInterface $taxon)
 {
     $this->indexPerTaxonPage->open(['taxonId' => $taxon->getId()]);
 }