Example #1
0
 public function __invoke($source)
 {
     try {
         $instance = $this->instanceManager->getInstanceFromRequest();
         return $this->aliasManager->findAliasBySource($source, $instance);
     } catch (Exception $e) {
         return $source;
     }
 }
 protected function refreshEntities(AdapterInterface $console, $percentile)
 {
     $entities = $this->entityManager->findAll(true);
     $filter = new HasCurrentRevisionCollectionFilter();
     $entities = $filter->filter($entities);
     $filter = new NotTrashedCollectionFilter();
     $entities = $filter->filter($entities);
     foreach ($entities as $entity) {
         if (rand(0, 100) > $percentile) {
             continue;
         }
         $instance = $entity->getInstance();
         $url = $this->aliasManager->getRouter()->assemble(['entity' => $entity->getId()], ['name' => 'entity/page']);
         $alias = $this->aliasManager->autoAlias('entity', $url, $entity, $instance);
         $console->writeLine('Updated entity ' . $entity->getId() . ': ' . $alias->getAlias());
     }
 }