Ejemplo n.º 1
0
 /**
  * Fire event
  * 
  * @return void
  */
 public function __invoke(ConsoleEvent $event)
 {
     $output = $event->getOutput();
     $output->writeln('');
     $output->writeln("Time: " . round(microtime(true) - $this->startTime, 6) . " seg");
     $output->writeln('');
 }
Ejemplo n.º 2
0
 /**
  * Display a warning if a running n98-magerun as root user
  *
  * @param ConsoleEvent $event
  * @return void
  */
 public function checkRunningAsRootUser(ConsoleEvent $event)
 {
     $output = $event->getOutput();
     if ($output instanceof ConsoleOutput) {
         $errorOutput = $output->getErrorOutput();
         if (OperatingSystem::isLinux() || OperatingSystem::isMacOs()) {
             if (function_exists('posix_getuid')) {
                 if (posix_getuid() === 0) {
                     $errorOutput->writeln('');
                     $errorOutput->writeln(self::WARNING_ROOT_USER);
                     $errorOutput->writeln('');
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @param ConsoleEvent $event
  */
 public function registerComposer(ConsoleEvent $event)
 {
     /*
      * Inject composer object in composer commands
      */
     $command = $event->getCommand();
     if (strstr(get_class($command), 'Composer\\Command\\')) {
         $io = new ConsoleIO($event->getInput(), $event->getOutput(), $command->getHelperSet());
         $contaoRootFolder = $command->getApplication()->getContaoRootFolder();
         $configFile = $contaoRootFolder . '/composer.json';
         $composer = Factory::create($io, $configFile);
         \chdir($contaoRootFolder);
         $command->setComposer($composer);
         $command->setIO($io);
     }
 }
Ejemplo n.º 4
0
    /**
     * Fire event
     * 
     * @return void
     */
    public function __invoke(ConsoleEvent $event)
    {
        $header = <<<TEXT
 ____    __                       
/\\  _`\\ /\\ \\                      
\\ \\ \\L\\ \\ \\ \\___     ___   __  _  
 \\ \\ ,__/\\ \\  _ `\\  / __`\\/\\ \\/'\\ 
  \\ \\ \\/  \\ \\ \\ \\ \\/\\ \\L\\ \\/>  </ 
   \\ \\_\\   \\ \\_\\ \\_\\ \\____//\\_/\\_\\
    \\/_/    \\/_/\\/_/\\/___/ \\//\\/_/
                                  

TEXT;
        $output = $event->getOutput();
        $output->writeln($header);
    }
 public function report(ConsoleEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $output = $event->getOutput();
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $stat = ServiceCallsStatistics::getCalls();
         $tableFormatter = new Table($output);
         $tableFormatter->setHeaders(['Class Name', 'Api Path', 'Parameters']);
         foreach ($stat as $row) {
             $tableFormatter->addRow([$row[0], $row[0]::API_METHOD, json_encode($row[1])]);
         }
         $tableFormatter->render();
         if ($dispatcher instanceof TraceableEventDispatcher) {
             print_r($dispatcher->getCalledListeners());
         }
     }
     $event->stopPropagation();
 }
Ejemplo n.º 6
0
 /**
  * Fire event
  * 
  * @return void
  */
 public function __invoke(ConsoleEvent $event)
 {
     $output = $event->getOutput();
     $output->writeln("<comment>Dependencies validation:</comment>");
     $output->write(str_pad("Phar extension is loaded?", 30, '.'));
     $error = false;
     if (!extension_loaded('phar')) {
         $output->writeln('<error>NOK</error>');
         $error = true;
     } else {
         $output->writeln('<info>OK</info>');
     }
     $output->write(str_pad("phar.readonly is On?", 30, '.'));
     if (!\Phar::canWrite()) {
         $output->writeln('<error>NOK</error>');
         $error = true;
     } else {
         $output->writeln('<info>OK</info>');
     }
     if ($error) {
         exit(1);
     }
 }
 /**
  * Flush cache manager when console terminates or errors
  *
  * @throws ExceptionCollection If an exception occurs during flush.
  */
 public function onConsoleTerminate(ConsoleEvent $event)
 {
     $num = $this->cacheManager->flush();
     if ($num > 0 && OutputInterface::VERBOSITY_VERBOSE <= $event->getOutput()->getVerbosity()) {
         $event->getOutput()->writeln(sprintf('Sent %d invalidation request(s)', $num));
     }
 }