Esempio n. 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;
 }
 protected function process(TaxonomyTermInterface $term)
 {
     if (!$term->hasParent()) {
         return;
     }
     if ($term->getId() === null) {
         $this->getAliasManager()->flush($term);
     }
     $instance = $term->getInstance();
     $normalizer = $this->normalizer->normalize($term);
     $routeName = $normalizer->getRouteName();
     $routeParams = $normalizer->getRouteParams();
     $router = $this->getAliasManager()->getRouter();
     $url = $router->assemble($routeParams, ['name' => $routeName]);
     $this->getAliasManager()->autoAlias('taxonomyTerm', $url, $term, $instance);
     foreach ($term->getChildren() as $child) {
         $this->process($child);
     }
 }