protected function refreshTerms(AdapterInterface $console, $percentile) { $filter = new NotTrashedCollectionFilter(); $terms = $this->taxonomyManager->findAllTerms(true); $terms = $filter->filter($terms); foreach ($terms as $term) { if (rand(0, 100) > $percentile) { continue; } $instance = $term->getInstance(); $normalizer = $this->normalizer->normalize($term); $routeName = $normalizer->getRouteName(); $routeParams = $normalizer->getRouteParams(); $router = $this->aliasManager->getRouter(); $url = $router->assemble($routeParams, ['name' => $routeName]); $alias = $this->aliasManager->autoAlias('taxonomyTerm', $url, $term, $instance); $console->writeLine('Updated taxonomy term ' . $term->getName() . ' (' . $term->getId() . '): ' . $alias->getAlias()); } }