Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @param Search                    $search
  * @param IndexManager              $manager
  * @param StreamRepositoryInterface $streams
  */
 public function fire(Search $search, IndexManager $manager, StreamRepositoryInterface $streams, EntryRepositoryInterface $repository)
 {
     $stream = $this->argument('stream');
     list($namespace, $slug) = explode('.', $stream);
     if (!($stream = $streams->findBySlugAndNamespace($slug, $namespace))) {
         $this->error('Stream [' . $this->argument('stream') . '] could not be found.');
         return;
     }
     /* @var EntryModel $model */
     $repository->setModel($model = $stream->getEntryModel());
     /**
      * If the stream is empty we can't
      * really index it.
      */
     if (!($entry = $repository->first())) {
         $this->error('Stream [' . $this->argument('stream') . '] is empty.');
     }
     /**
      * If the stream does not have a valid
      * search configuration then we don't
      * know how to insert it's entries.
      */
     if (!($config = $this->dispatch(new GetConfig($entry)))) {
         $this->error('Stream [' . $this->argument('stream') . '] does not have a search configuration.');
     }
     $this->info('Deleting ' . $this->argument('stream'));
     $search->search('stream', $stream)->delete();
     $this->info('Rebuilding ' . $this->argument('stream'));
     $this->output->progressStart($repository->count());
     foreach ($repository->all() as $entry) {
         $manager->insert($entry, $config);
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }
Exemplo n.º 2
0
 /**
  * Handle the command.
  *
  * @param IndexManager $manager
  */
 public function handle(IndexManager $manager)
 {
     $manager->delete($this->entry, $this->config);
 }
Exemplo n.º 3
0
 /**
  * Execute the console command.
  */
 public function fire(IndexManager $manager)
 {
     $manager->destroy();
     $this->info('Search index destroyed!');
 }