mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-30 23:52:40 +01:00
e83d2eedbb
- Also aligned format of command descriptions. Targeted most common columns. Have not done revisions for the sake of keeping that content true to how it was originally stored but could cause unexpected behaviour. For #1225
56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace BookStack\Console\Commands;
|
|
|
|
use BookStack\Entities\SearchService;
|
|
use DB;
|
|
use Illuminate\Console\Command;
|
|
|
|
class RegenerateSearch extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'bookstack:regenerate-search {--database= : The database connection to use.}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Re-index all content for searching';
|
|
|
|
protected $searchService;
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @param SearchService $searchService
|
|
*/
|
|
public function __construct(SearchService $searchService)
|
|
{
|
|
parent::__construct();
|
|
$this->searchService = $searchService;
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
$connection = DB::getDefaultConnection();
|
|
if ($this->option('database') !== null) {
|
|
DB::setDefaultConnection($this->option('database'));
|
|
$this->searchService->setConnection(DB::connection($this->option('database')));
|
|
}
|
|
|
|
$this->searchService->indexAllEntities();
|
|
DB::setDefaultConnection($connection);
|
|
$this->comment('Search index regenerated');
|
|
}
|
|
}
|