]> _ Git - cubist_cms-back.git/commitdiff
wip #4050 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 Nov 2020 18:51:49 +0000 (19:51 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 Nov 2020 18:51:49 +0000 (19:51 +0100)
src/app/Magic/Models/CubistMagicAbstractModel.php
src/resources/cubistmagic/Controller.stub

index 949cb97c750acef70f5567748e4b4f1fd677a414..071543dbaf6a954c116d573cfa1318e7fb8c9cc1 100644 (file)
@@ -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) {
index 8502f055427283b66fcec2fdee4cf4c95ab44a13..e327369ff02bc133650dc49e129a30d53d9532f6 100644 (file)
@@ -4,6 +4,8 @@ namespace App\Http\Controllers\Admin;
 
 class _CONTROLLERCLASS_ extends _EXTENDS_
 {
+    _USE_
+
     protected $_modelNamespace = '_MODELNAMESPACE_';
     protected $_routeURL = '_ROUTEURL_';
     protected $_singular = '_SINGULAR_';