From: Vincent Vanwaelscappel Date: Thu, 5 Nov 2020 18:51:49 +0000 (+0100) Subject: wip #4050 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=de09a0c74ef30e3f5ad6b4400992cb5066b0a1e3;p=cubist_cms-back.git wip #4050 @0.5 --- diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index 949cb97..071543d 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -38,6 +38,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia protected $connection = null; protected $primaryKey = 'id'; + protected $_operations = []; public $timestamps = true; public $clonable = true; protected $_syncDbSchema = true; @@ -294,6 +295,15 @@ class CubistMagicAbstractModel extends Model implements HasMedia return $this->_baseController; } + protected function _getUse() + { + $res = ''; + foreach ($this->_operations as $operation) { + $res .= 'use ' . $operation . ';' . "\n"; + } + return $res; + } + protected function _replaceInCode($stub, $dest) { $vars = ['CONTROLLERCLASS' => $this->getControllerClass(), @@ -304,7 +314,8 @@ class CubistMagicAbstractModel extends Model implements HasMedia 'EXTENDS' => '\\' . $this->_getBaseController(), 'CLONABLE' => $this->clonable ? 'true' : 'false', 'BULK' => $this->getOption('bulk', true) ? 'true' : 'false', - 'ONEINSTANCE' => $this->getOption('oneinstance', false) ? 'true' : 'false']; + 'ONEINSTANCE' => $this->getOption('oneinstance', false) ? 'true' : 'false', + 'USE' => $this->_getUse()]; $res = file_get_contents($stub); foreach ($vars as $name => $value) { diff --git a/src/resources/cubistmagic/Controller.stub b/src/resources/cubistmagic/Controller.stub index 8502f05..e327369 100644 --- a/src/resources/cubistmagic/Controller.stub +++ b/src/resources/cubistmagic/Controller.stub @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Admin; class _CONTROLLERCLASS_ extends _EXTENDS_ { + _USE_ + protected $_modelNamespace = '_MODELNAMESPACE_'; protected $_routeURL = '_ROUTEURL_'; protected $_singular = '_SINGULAR_';