Example #1
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;
 }
Example #2
0
 protected function iterAssociationNodes(Collection $collection, TaxonomyTermInterface $term, $associations, array $allowedTaxonomies)
 {
     foreach ($term->getAssociated($associations) as $link) {
         $collection->add($link);
     }
     foreach ($term->getChildren() as $child) {
         if (empty($allowedTaxonomies) || in_array($child->getTaxonomy()->getName(), $allowedTaxonomies)) {
             $this->iterAssociationNodes($collection, $child, $associations, $allowedTaxonomies);
         }
     }
 }