mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-14 07:07:21 +08:00
307fae39c4
For book, shelves and chapters. Made much of the existing handling generic to entity types. Added new MixedEntityListLoader to help load lists somewhat efficiently. Only manually tested so far.
46 lines
1.0 KiB
PHP
46 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace BookStack\Console\Commands;
|
|
|
|
use BookStack\References\ReferenceStore;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class RegenerateReferencesCommand extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'bookstack:regenerate-references
|
|
{--database= : The database connection to use}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Regenerate all the cross-item model reference index';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle(ReferenceStore $references): int
|
|
{
|
|
$connection = DB::getDefaultConnection();
|
|
|
|
if ($this->option('database')) {
|
|
DB::setDefaultConnection($this->option('database'));
|
|
}
|
|
|
|
$references->updateForAll();
|
|
|
|
DB::setDefaultConnection($connection);
|
|
|
|
$this->comment('References have been regenerated');
|
|
|
|
return 0;
|
|
}
|
|
}
|