Exemplo n.º 1
0
 /**
  * Called by: php oil r movescaffoldtomodule
  * Moves scaffold files to module.
  */
 public function run($args = NULL)
 {
     /* We handle here options:
      *  * scaffold alias s: name of the scaffold to move
      *  * module alias m: module to move the scaffold into
      *  * force alias f: do we override existing files ?
      */
     $scaffold = \Cli::option('scaffold', \Cli::option('s'));
     $module = \Cli::option('module', \Cli::option('m'));
     static::$force = \Cli::option('force', \Cli::option('f', false));
     // Checking if the scaffold and module options are
     // defined
     if (is_null($scaffold) || is_null($module)) {
         \Cli::error('Some parameters are missing.');
         \Cli::error('Ex: php oil r moveScaffoldToModule' . ' -scaffold=category -module=blog');
         return;
     }
     $module_path = \Module::exists($module);
     // Is the module found ?
     if ($module_path == null) {
         \Cli::error('The specified module doesn\'t exists!');
         return;
     }
     // Now processing each scaffold file / folders
     foreach (static::$files_to_move as $item) {
         $path = str_replace('(:scaffold)', $scaffold, $item['path']);
         if (file_exists(APPPATH . $path)) {
             /*
              * As each file type must be processed
              * differently, a different method is called
              * depending on the type. For instance, if
              * the file type is controller, we will call
              * the process_controller method.
              */
             static::{'process_' . $item['type']}($path, $module, $module_path);
         }
     }
     // Processing migration as it is a special cases.
     static::process_migration($scaffold, $module, $module_path);
 }
Exemplo n.º 2
0
 /**
  * Merge the record with another structure
  *
  * @param mixed $mergee
  * @return static
  * @throws Exception
  */
 public function merge($mergee)
 {
     $data = $this->_recordData;
     $record = new static($this->_validator);
     foreach ($mergee as $key => $value) {
         $record->validate($key, $value);
         $data[$key] = $value;
     }
     $record->force($data);
     return $record;
 }