Пример #1
0
 protected function getFilePath($name, $forSqlFile = false, $forRollbackSqlFile = false)
 {
     $basePath = preg_replace('%[/\\\\]%', DIRECTORY_SEPARATOR, parent::getMigrationPath()) . DIRECTORY_SEPARATOR;
     if ($forSqlFile) {
         $basePath .= $this->sqlSubdir . DIRECTORY_SEPARATOR;
         if ($forRollbackSqlFile) {
             $basePath .= $this->sqlRollbackSubdir . DIRECTORY_SEPARATOR;
         }
     }
     if (!Folder::exist($basePath)) {
         Folder::add($basePath, 0775);
     }
     return $basePath . date('Y_m_d_His') . '_' . $name . ($forSqlFile ? '.sql' : '.php');
 }
Пример #2
0
 public function fire()
 {
     $appSubfolder = ucfirst(trim(trim($this->input->getArgument('app_subfolder')), '/\\'));
     $lowercasedSubfolder = snake_case($appSubfolder);
     $folderPath = app_path('/' . $appSubfolder);
     if (Folder::exist($folderPath)) {
         $this->line('Terminated. Folder [' . $folderPath . '] already exist');
     }
     $folder = Folder::load($folderPath, true, 0755);
     $dataForViews = ['sectionName' => $appSubfolder, 'urlPrefix' => trim(trim($this->input->getArgument('url_prefix'), '/\\')), 'dbClassesAppSubfolder' => $this->input->getArgument('database_classes_app_subfolder')];
     // create site loader
     $file = File::load($folder->pwd() . '/' . $appSubfolder . 'SiteLoader.php', true, 0755, 0644);
     $file->write(view('cmf::install.cmf_site_loader', $dataForViews)->render());
     // copy configs
     $subfolder = Folder::load($folder->pwd() . '/Config', true, 0755);
     $file = File::load($subfolder->pwd() . '/' . $appSubfolder . 'Config.php', true, 0755, 0644);
     $file->write(view('cmf::install.cmf_config', $dataForViews)->render());
     $file = File::load($subfolder->pwd() . '/' . $lowercasedSubfolder . '.routes.php', true, 0755, 0644);
     $file->write(view('cmf::install.cmf_routes', $dataForViews)->render());
     // copy pages controller
     $subfolder = Folder::load($folder->pwd() . '/Http/Controllers', true, 0755);
     $file = File::load($subfolder->pwd() . '/PagesController.php', true, 0755, 0644);
     $file->write(view('cmf::install.pages_controller', $dataForViews)->render());
     // create middleware folder
     File::load($folder->pwd() . '/Http/Middleware/empty', true, 0755, 0644);
     // make folder in resources
     File::load(resource_path('/views/' . $lowercasedSubfolder . '/empty'), true, 0755, 0644);
     if (!$this->input->getOption('no-db-classes')) {
         // copy base db classes
         $dbFolder = Folder::load(app_path('/' . $this->input->getArgument('database_classes_app_subfolder')), true, 0755);
         $file = File::load($dbFolder->pwd() . '/BaseDbModel.php', true, 0755, 0644);
         $file->write(view('cmf::install.db.base_db_model')->render());
         $file = File::load($dbFolder->pwd() . '/BaseDbObject.php', true, 0755, 0644);
         $file->write(view('cmf::install.db.base_db_object')->render());
         // copy admin table classes
         $subfolder = Folder::load($dbFolder->pwd() . '/Admin', true, 0755);
         $file = File::load($subfolder->pwd() . '/Admin.php', true, 0755, 0644);
         $file->write(view('cmf::install.db.admin_object')->render());
         $file = File::load($subfolder->pwd() . '/AdminModel.php', true, 0755, 0644);
         $file->write(view('cmf::install.db.admin_model')->render());
         $file = File::load($subfolder->pwd() . '/AdminTableConfig.php', true, 0755, 0644);
         $file->write(view('cmf::install.db.admin_table_config')->render());
         $file = File::load($subfolder->pwd() . '/AdminScaffoldConfig.php', true, 0755, 0644);
         $file->write(view('cmf::install.db.admin_scaffold_config')->render());
     }
     $this->line('Done');
 }