コード例 #1
0
 protected function clearParents(TaxonomyTermInterface $term)
 {
     if ($term->hasParent()) {
         $parent = $term->getParent();
         $this->cacheService->clearByTags(['route_taxonomy/term/get', 'param_term_' . $parent->getId()]);
         $this->clearParents($parent);
     }
 }
コード例 #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;
 }
コード例 #4
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() . '/' : '';
 }