|
|
@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Services\ModelFinder;
|
|
|
|
use App\Services\MorphModelFinder;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
|
|
|
|
class CacheMorphMap extends Command
|
|
|
|
class CacheMorphMap extends Command
|
|
|
@ -22,20 +22,20 @@ class CacheMorphMap extends Command
|
|
|
|
protected $description = 'Create a cache file for faster morph mapping';
|
|
|
|
protected $description = 'Create a cache file for faster morph mapping';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @var ModelFinder
|
|
|
|
* @var MorphModelFinder
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $modelFinder;
|
|
|
|
private $morphModelFinder;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param ModelFinder $modelFinder
|
|
|
|
* @param MorphModelFinder $morphModelFinder
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function __construct(ModelFinder $modelFinder)
|
|
|
|
public function __construct(MorphModelFinder $morphModelFinder)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
|
|
|
|
$this->modelFinder = $modelFinder;
|
|
|
|
$this->morphModelFinder = $morphModelFinder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -45,10 +45,10 @@ class CacheMorphMap extends Command
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function handle(): void
|
|
|
|
public function handle(): void
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$cache = $this->modelFinder->getCachePath();
|
|
|
|
$cache = $this->morphModelFinder->getCachePath();
|
|
|
|
|
|
|
|
|
|
|
|
$models = $this->modelFinder->getModels();
|
|
|
|
$models = $this->morphModelFinder->getModels();
|
|
|
|
$map = $this->modelFinder->getModelMap($models);
|
|
|
|
$map = $this->morphModelFinder->getModelMap($models);
|
|
|
|
|
|
|
|
|
|
|
|
file_put_contents(
|
|
|
|
file_put_contents(
|
|
|
|
$cache,
|
|
|
|
$cache,
|
|
|
|