/**
  * @param TaxonomyTermInterface $term
  * @param array                 $array
  */
 protected function retrieveTerms(TaxonomyTermInterface $term, array &$array)
 {
     while ($term->hasParent()) {
         $name = $term->getTaxonomy()->getName();
         $array[$name][] = $term->getName();
         $term = $term->getParent();
     }
 }
Пример #2
0
 protected function getPath(TaxonomyTermInterface $taxonomyTerm, $string = null)
 {
     $name = $taxonomyTerm->getName();
     $parent = $taxonomyTerm->getParent();
     $string = $name . '/' . $string;
     if ($parent && $parent->getTaxonomy()->getName() != 'root') {
         return $this->getPath($parent, $string);
     }
     return $string;
 }
Пример #3
0
 protected function ajaxify(TaxonomyTermInterface $term)
 {
     $data = ['id' => $term->getId(), 'name' => $term->getName(), 'taxonomy' => $term->getTaxonomy()->getId(), 'url' => $this->url()->fromRoute('uuid/get', ['uuid' => $term->getId()]), 'parent' => $term->hasParent() ? $term->getParent()->getId() : null, 'children' => [], 'items' => []];
     foreach ($term->getChildren() as $child) {
         $data['children'][] = $this->ajaxify($child);
     }
     foreach ($term->getAssociated('entities') as $child) {
         $data['items'][] = ['id' => $child->getId(), 'type' => 'entity'];
     }
     return $data;
 }
 protected function removeMetadata($object, TaxonomyTermInterface $term)
 {
     while ($term->hasParent()) {
         try {
             $metadata = $this->getMetadataManager()->findMetadataByObjectAndKeyAndValue($object, $term->getTaxonomy()->getName(), $term->getName());
             $this->getMetadataManager()->removeMetadata($metadata->getId());
         } catch (MetadataNotFoundException $e) {
         }
         $term = $term->getParent();
     }
 }
Пример #5
0
 /**
  * @param TaxonomyInterface|TaxonomyTermInterface|string $nameOrObject
  * @throws Exception\InvalidArgumentException
  * @return \Taxonomy\Options\TaxonomyOptions
  */
 public function getOptions($nameOrObject)
 {
     if ($nameOrObject instanceof TaxonomyInterface) {
         $name = $nameOrObject->getName();
     } elseif ($nameOrObject instanceof TaxonomyTermInterface) {
         $name = $nameOrObject->getTaxonomy()->getName();
     } elseif (is_string($nameOrObject)) {
         $name = $nameOrObject;
     } else {
         throw new Exception\InvalidArgumentException(sprintf('Expected $nameOrObject to be TaxonomyInterface, TaxonomyTermInterface or string but got "%s"', is_object($nameOrObject) ? get_class($nameOrObject) : gettype($nameOrObject)));
     }
     return $this->moduleOptions->getType($name);
 }
Пример #6
0
 /**
  * @param TaxonomyTermInterface $term
  * @param string                $parent
  * @return string
  */
 protected function processSlugs(TaxonomyTermInterface $term, $parent)
 {
     return $term->getTaxonomy()->getName() != $parent ? $this->processSlugs($term->getParent(), $parent) . $term->getName() . '/' : '';
 }