Beispiel #1
0
 /**
  * @param Registrator       $registrator
  * @param ConsoleDispatcher $dispatcher
  */
 public function perform(Registrator $registrator, ConsoleDispatcher $dispatcher)
 {
     $class = $this->guessClass($this->argument('module'));
     if (!$this->isModule($class)) {
         $this->writeln("<fg=red>Class '{$class}' is not valid module.</fg=red>");
         return;
     }
     //Altering all requested module configurations
     $this->container->get($class)->register($registrator);
     /**
      * Sometimes modules request to alter some config files, we need user confirmation for that.
      */
     if (!empty($registrator->getInjected())) {
         $table = $this->tableHelper(['Config', 'Section', 'Added Lines']);
         foreach ($registrator->getInjected() as $injected) {
             $table->addRow(["<info>{$injected['config']}</info>", "{$injected['placeholder']}", join("\n", $injected['lines'])]);
         }
         //todo: better english
         $this->writeln("<comment>Module requests following configs to be altered:</comment>");
         $table->render();
         $this->writeln("");
         if (!$this->ask()->confirm("Confirm module registration (y/n)")) {
             return;
         }
         $this->writeln("");
     }
     //Let's save all updated configs now
     $registrator->save();
     $this->writeln("<info>Module '<comment>{$class}</comment>' has been successfully registered.</info>");
     $dispatcher->command('publish', $this->input, $this->output);
 }
Beispiel #2
0
 /**
  * @param ConsoleConfig     $config
  * @param ConsoleDispatcher $dispatcher
  */
 public function perform(ConsoleConfig $config, ConsoleDispatcher $dispatcher)
 {
     foreach ($config->updateSequence() as $command => $options) {
         if (!empty($options['header'])) {
             $this->writeln($options['header']);
         }
         $dispatcher->command($command, $options['options'], $this->output);
         if (!empty($options['footer'])) {
             $this->writeln($options['footer']);
         }
     }
 }
Beispiel #3
0
 /**
  * @param ConsoleConfig        $config
  * @param ConsoleDispatcher    $dispatcher
  * @param DirectoriesInterface $directories
  * @param FilesInterface       $files
  */
 public function perform(ConsoleConfig $config, ConsoleDispatcher $dispatcher, DirectoriesInterface $directories, FilesInterface $files)
 {
     $this->ensurePermissions($directories, $files);
     $this->writeln("\n<info>Re-indexing available console commands...</info>");
     $dispatcher->command('console:reload', [], $this->output);
     $this->writeln("\n<info>Reloading bootload cache...</info>");
     $dispatcher->command('app:reload', [], $this->output);
     $this->writeln("\n<info>Re-loading translator locales cache...</info>");
     $dispatcher->command('i18n:reload', [], $this->output);
     $this->writeln("\n<info>Scanning translate function and [[values]] usage...</info>");
     $dispatcher->command('i18n:index', [], $this->output);
     $this->writeln("");
     //Additional commands
     foreach ($config->configureSequence() as $command => $options) {
         if (!empty($options['header'])) {
             $this->writeln($options['header']);
         }
         $dispatcher->command($command, $options['options'], $this->output);
         if (!empty($options['footer'])) {
             $this->writeln($options['footer']);
         }
     }
     if ($this->option('key')) {
         $this->writeln("");
         $dispatcher->command('app:key', [], $this->output);
     }
     $this->writeln("\n<info>All done!</info>");
 }
Beispiel #4
0
 /**
  * @param ViewLocator       $locator
  * @param ViewManager       $manager
  * @param ConsoleDispatcher $dispatcher
  */
 public function perform(ViewLocator $locator, ViewManager $manager, ConsoleDispatcher $dispatcher)
 {
     //To clean up cache
     $dispatcher->command('views:reset', [], $this->output);
     if ($this->isVerbosity()) {
         $this->write("\n");
     }
     /**
      * @var FormatterHelper $formatter
      */
     $formatter = $this->getHelper('formatter');
     foreach ($locator->getNamespaces() as $namespace) {
         $this->isVerbosity() && $this->writeln("Compiling views in namespace '<comment>{$namespace}</comment>'.");
         foreach ($locator->namespaceViews($namespace) as $view => $engine) {
             if ($this->isVerbosity()) {
                 $this->write($formatter->formatSection("{$namespace}:{$engine}", $view . ", ", 'fg=cyan'));
             }
             $benchmark = $this->benchmark('compile');
             try {
                 //Compilation
                 $manager->engine($engine)->compile("{$namespace}:{$view}", true);
                 $this->isVerbosity() && $this->write("<info>ok</info>");
             } catch (\Exception $exception) {
                 if ($this->isVerbosity()) {
                     $this->write("<fg=red>error: {$exception->getMessage()}</fg=red>");
                 }
             } finally {
                 $elapsed = number_format($this->benchmark($benchmark) * 1000);
                 if ($this->isVerbosity()) {
                     $this->writeln(" <comment>[{$elapsed} ms]</comment> ");
                 }
             }
         }
     }
     $this->writeln("<info>View cache was successfully generated.</info>");
 }
Beispiel #5
0
 /**
  * @param ConsoleDispatcher $dispatcher
  */
 public function perform(ConsoleDispatcher $dispatcher)
 {
     $commands = count($dispatcher->locateCommands());
     $this->writeln("Console commands re-indexed, <comment>{$commands}</comment> commands found.");
 }