コード例 #1
0
 /**
  * Get module
  *
  * @throws ModuleNotFoundException
  *
  * @return Module
  */
 protected function getModule()
 {
     /** @var Command $this */
     $module = $this->argument('module') ?: workbench()->getUsedNow();
     /** @var string $module */
     return workbench()->findOrFail($module);
 }
コード例 #2
0
ファイル: DumpCommand.php プロジェクト: arcanedev/workbench
 /**
  * Dump module
  *
  * @param string $module
  */
 private function dump($module)
 {
     $module = workbench()->findOrFail($module);
     $this->line("<comment>Running for module</comment>: {$module}");
     chdir($module->getPath());
     passthru('composer dump -o -n -q');
 }
コード例 #3
0
 /**
  * Run the migration from the specified module.
  *
  * @param string $name
  */
 private function migrate($name)
 {
     $module = workbench()->findOrFail($name);
     $this->call('migrate', ['--path' => $this->getPath($module), '--database' => $this->getStringOption('db'), '--pretend' => $this->getBoolOption('pretend'), '--force' => $this->getBoolOption('force')]);
     if ($this->getBoolOption('seed')) {
         $this->call('module:seed', ['module' => $name]);
     }
 }
コード例 #4
0
ファイル: MakeCommand.php プロジェクト: arcanedev/workbench
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach ($this->getNames() as $name) {
         (new ModuleGenerator($name))->setFilesystem(app('files'))->setWorkbench(workbench())->setConfig(config())->setConsole($this)->setForce($this->getBoolOption('force'))->setPlain($this->getBoolOption('plain'))->generate();
     }
     $this->line('<comment>Dump all modules autoload</comment>');
     chdir(base_path());
     passthru('composer dump -o -n -q');
 }
コード例 #5
0
ファイル: UseCommand.php プロジェクト: arcanedev/workbench
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $module = str_studly($this->getStringArg('module'));
     if (!workbench()->has($module)) {
         workbench()->setUsed($module);
         $this->info("Module [{$module}] used successfully.");
     } else {
         $this->error("Module [{$module}] does not exists.");
     }
 }
コード例 #6
0
 /**
  * Rollback migration from the specified module.
  *
  * @param Module|string $module
  */
 private function reset($module)
 {
     if (is_string($module)) {
         $module = workbench()->findOrFail($module);
     }
     $this->line('Running for module: <info>' . $module->getName() . '</info>');
     $migrated = (new Migrator($module))->reset();
     if (count($migrated)) {
         foreach ($migrated as $migration) {
             $this->line("Rollback: <info>{$migration}</info>");
         }
     } else {
         $this->comment('Nothing to rollback.');
     }
 }
コード例 #7
0
ファイル: ListCommand.php プロジェクト: arcanedev/workbench
 /**
  * Get modules.
  *
  * @return array
  */
 private function getModules()
 {
     $workbench = workbench();
     if (!$this->option('only')) {
         return workbench()->all();
     }
     $choice = $this->anticipate('Select only modules that are ?', ['enabled', 'disabled', 'ordered']);
     switch ($choice) {
         case 'enabled':
             return $workbench->getByStatus(1);
             // no break
         // no break
         case 'disabled':
             return $workbench->getByStatus(0);
             // no break
         // no break
         case 'ordered':
         default:
             return $workbench->getOrdered($this->getStringOption('dir'));
             // no break
     }
 }
コード例 #8
0
ファイル: SetupCommand.php プロジェクト: arcanedev/workbench
 /**
  * Generate the assets folder.
  */
 private function makeAssetsFolder()
 {
     $this->generateDirectory(workbench()->config('paths.assets'), 'Assets directory created successfully', 'Assets directory already exist');
 }
コード例 #9
0
ファイル: BenchCommand.php プロジェクト: arcanedev/workbench
 /**
  * Get the destination file path.
  *
  * @param  string  $name
  *
  * @throws InvalidFileNameException
  *
  * @return string
  */
 protected function getDestinationFilePath($name = '')
 {
     $modulePath = workbench()->getModulePath($this->getModuleName());
     $filePath = workbench()->config('paths.generator.' . $name, '');
     return $modulePath . $filePath . '/' . $this->getFileName() . '.php';
 }
コード例 #10
0
 /**
  * Get template contents.
  *
  * @return string
  */
 protected function getTemplateContents()
 {
     $module = $this->getModule();
     return Stub::create('/request.stub', ['MODULE' => $module->getStudlyName(), 'NAME' => $this->getFileName(), 'MODULE_NAMESPACE' => workbench()->config('namespace'), 'NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass()])->render();
 }
コード例 #11
0
ファイル: UpdateCommand.php プロジェクト: arcanedev/workbench
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     workbench()->update($name = $this->getModuleName());
     $this->info("Module [{$name}] updated successfully.");
 }
コード例 #12
0
 /**
  * Publish migration for the specified module.
  *
  * @param Module $module
  */
 private function publish(Module $module)
 {
     (new MigrationPublisher($module))->setWorkbench(workbench())->setConsole($this)->publish();
 }
コード例 #13
0
 /**
  * Install the specified module.
  *
  * @param string $name
  * @param string $version
  * @param string $type
  * @param bool   $tree
  */
 private function install($name, $version = 'dev-master', $type = 'composer', $tree = false)
 {
     $installer = new Installer($name, $version, $type ?: $this->getStringOption('type'), $tree ?: $this->getBoolOption('tree'));
     $installer->setRepository(workbench());
     $installer->setConsole($this);
     if ($timeout = $this->option('timeout')) {
         $installer->setTimeout((int) $timeout);
     }
     if ($path = $this->getStringOption('path')) {
         $installer->setPath($path);
     }
     $installer->run();
     if (!$this->option('no-update')) {
         $this->call('module:update', ['module' => $installer->getModuleName()]);
     }
 }
コード例 #14
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     workbench()->register();
 }
コード例 #15
0
 /**
  * Get migration generator path.
  *
  * @return string
  */
 protected function getMigrationGeneratorPath()
 {
     return workbench()->config('paths.generator.migration');
 }
コード例 #16
0
 /**
  * Get template contents.
  *
  * @return string
  */
 protected function getTemplateContents()
 {
     return Stub::create('/seeder.stub', ['NAME' => $this->getFileName(), 'MODULE' => $this->getModuleName(), 'MODULE_NAMESPACE' => workbench()->config('namespace')])->render();
 }
コード例 #17
0
 /**
  * Get template contents.
  *
  * @return string
  */
 protected function getTemplateContents()
 {
     $stub = ($this->option('master') == 'scaffold' ? 'scaffold/' : '') . 'provider';
     $module = workbench()->findOrFail($this->getModuleName());
     return Stub::create('/' . $stub . '.stub', ['NAMESPACE' => $this->getClassNamespace($module), 'CLASS' => $this->getClass(), 'LOWER_NAME' => $module->getLowerName()])->render();
 }
コード例 #18
0
 /**
  * Publish assets from the specified module.
  *
  * @param Module|string $name
  */
 private function publish($name)
 {
     $module = $name instanceof Module ? $name : workbench()->findOrFail($name);
     (new AssetPublisher($module))->setWorkbench(workbench())->setConsole($this)->publish();
     $this->line("<info>Published</info>: {$module->getStudlyName()}");
 }
コード例 #19
0
ファイル: SeedCommand.php プロジェクト: arcanedev/workbench
 /**
  * Get master database seeder name for the specified module.
  *
  * @param string $name
  *
  * @return string
  */
 private function getSeederName($name)
 {
     $name = str_studly($name);
     $namespace = workbench()->config('namespace');
     return $namespace . '\\' . $name . '\\Database\\Seeders\\' . $name . 'DatabaseSeeder';
 }