Exemplo n.º 1
0
 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());
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function provide()
 {
     $notTrashed = new NotTrashedCollectionFilter();
     $hasCurrent = new HasCurrentRevisionCollectionFilter();
     $chain = new FilterChain();
     $chain->attach($notTrashed);
     $chain->attach($hasCurrent);
     $container = [];
     $types = $this->options->getTypes();
     foreach ($types as $type) {
         if ($type->hasComponent('search')) {
             /* @var $component SearchOptions */
             $component = $type->getComponent('search');
             if ($component->getEnabled()) {
                 $name = $type->getName();
                 $entities = $this->entityManager->findEntitiesByTypeName($name, true);
                 $entities = $chain->filter($entities);
                 $this->addEntitiesToContainer($entities, $container);
             }
         }
     }
     return $container;
 }