]> _ Git - cubist_cms-back.git/commitdiff
#2783
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 May 2019 16:56:48 +0000 (18:56 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 May 2019 16:56:48 +0000 (18:56 +0200)
src/app/Console/Commands/MagicCubistCommand.php
src/app/Magic/Models/CubistMagicModelAbstract.php

index c68d31b5f4028a5e1ee008eac0057caa1c5b7061..434b91c1f109a8c37a2a2a3993f8a68d3714948f 100644 (file)
@@ -50,6 +50,7 @@ class MagicCubistCommand extends Command
         $this->line('Handling folder ' . $folder);
         $iterator = Files::getDirectoryIterator($folder, true);
         foreach ($iterator as $item) {
+            $this->line('Testing ' . $item);
             /** @var $item \SplFileInfo */
             if ($item->isFile() && $item->getExtension() == 'php') {
                 $class = PHP::instanciateClassInFile($item);
@@ -64,15 +65,15 @@ class MagicCubistCommand extends Command
     /**
      * Run a SSH command.
      *
-     * @param string $command      The SSH command that needs to be run
-     * @param bool   $beforeNotice Information for the user before the command is run
-     * @param bool   $afterNotice  Information for the user after the command is run
+     * @param string $command The SSH command that needs to be run
+     * @param bool $beforeNotice Information for the user before the command is run
+     * @param bool $afterNotice Information for the user after the command is run
      *
      * @return mixed Command-line output
      */
     public function executeProcess($command, $beforeNotice = false, $afterNotice = false)
     {
-        $this->echo('info', $beforeNotice ? ' '.$beforeNotice : $command);
+        $this->echo('info', $beforeNotice ? ' ' . $beforeNotice : $command);
 
         $process = new Process($command, null, null, null, $this->option('timeout'), null);
         $process->run(function ($type, $buffer) {
index 0232730536e47fa82c11d7180aea11871ea2c279..170a36c575c7ce0cbc62c35d820757a8cbf372e9 100644 (file)
@@ -3,12 +3,10 @@
 
 namespace Cubist\Backpack\app\Magic\Models;
 
-use Cubist\Backpack\app\Magic\Controllers\CubistMagicController;
 use Cubist\Backpack\app\Magic\Fields\CubistMagicField;
 use Illuminate\Database\Eloquent\Model;
 use Cubist\Backpack\app\Magic\CubistMagicAttribute;
 use Illuminate\Support\Facades\Route;
-use Backpack\CRUD;
 use Illuminate\Support\Str;
 
 class CubistMagicModelAbstract extends Model
@@ -21,9 +19,27 @@ class CubistMagicModelAbstract extends Model
      */
     protected $_fields = [];
 
+    /**
+     * @var array
+     */
+    protected $_options = [];
+
     public function __construct(array $attributes = [])
     {
         parent::__construct($attributes);
+        $this->init();
+    }
+
+    public function init(){
+
+    }
+
+    public function getOption($key, $default = null)
+    {
+        if (isset($this->_options[$key])) {
+            return $this->_options[$key];
+        }
+        return $default;
     }
 
     /**
@@ -63,9 +79,9 @@ class CubistMagicModelAbstract extends Model
     protected function _replaceInCode($stub, $dest)
     {
         $vars = ['CAMELNAME' => $this->getCamelName(),
-            'ROUTEURL' => $this->getAttribute('name'),
-            'SINGULAR' => $this->getAttribute('singular', $this->getAttribute('name')),
-            'PLURAL' => $this->getAttribute('plural', ''),
+            'ROUTEURL' => $this->getOption('name'),
+            'SINGULAR' => $this->getOption('singular', $this->getOption('name')),
+            'PLURAL' => $this->getOption('plural', ''),
             'MODELNAMESPACE' => __NAMESPACE__ . '\\' . get_class($this),
             'FIELDS' => var_export($this->_fields, true)
         ];
@@ -85,6 +101,6 @@ class CubistMagicModelAbstract extends Model
 
     public function getCamelName()
     {
-        return Str::camel($this->getAttribute('name'));
+        return Str::camel($this->getOption('name'));
     }
 }