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); } }
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; }
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; }
/** * @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() . '/' : ''; }