Exemplo n.º 1
0
    /**
     * @param \Symfony\Component\Console\Input\InputInterface $input
     * @param \Symfony\Component\Console\Output\OutputInterface $output
     * @return int|void
     * @throws RuntimeException
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $initialized = false;
        try {
            $this->detectMagento($output);
            $initialized = $this->initMagento();
        } catch (\Exception $e) {
            // do nothing
        }
        $consoleOutput = new ShellOutput();
        $config = new Configuration();
        $shell = new Shell($config);
        if ($initialized) {
            $ok = Charset::convertInteger(Charset::UNICODE_CHECKMARK_CHAR);
            $edition = $this->getApplication()->isMagentoEnterprise() ? 'EE' : 'CE';
            $consoleOutput->writeln('<fg=black;bg=green>Magento ' . \Mage::getVersion() . ' ' . $edition . ' initialized.</fg=black;bg=green> ' . $ok);
        } else {
            $consoleOutput->writeln('<fg=black;bg=yellow>Magento is not initialized.</fg=black;bg=yellow>');
        }
        $help = <<<'help'
At the prompt, type <comment>help</comment> for some help.

To exit the shell, type <comment>^D</comment>.
help;
        $consoleOutput->writeln($help);
        $shell->run($input, $consoleOutput);
    }
Exemplo n.º 2
0
    /**
     * @param InputInterface  $input
     * @param OutputInterface $output
     *
     * @return int|void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $initialized = false;
        try {
            $this->detectMagento($output);
            $initialized = $this->initMagento();
        } catch (Exception $e) {
            // do nothing
        }
        $parser = new Parser(new Lexer());
        $cleaner = new CodeCleaner($parser);
        $consoleOutput = new ShellOutput();
        $config = new Configuration();
        $config->setCodeCleaner($cleaner);
        $shell = new Shell($config);
        $shell->setScopeVariables(['di' => $this->getObjectManager()]);
        if ($initialized) {
            $ok = Charset::convertInteger(Charset::UNICODE_CHECKMARK_CHAR);
            $edition = $this->productMeta->getEdition();
            $magentoVersion = $this->productMeta->getVersion();
            $consoleOutput->writeln('<fg=black;bg=green>Magento ' . $magentoVersion . ' ' . $edition . ' initialized.</fg=black;bg=green> ' . $ok);
        } else {
            $consoleOutput->writeln('<fg=black;bg=yellow>Magento is not initialized.</fg=black;bg=yellow>');
        }
        $help = <<<'help'
At the prompt, type <comment>help</comment> for some help.

To exit the shell, type <comment>^D</comment>.
help;
        $consoleOutput->writeln($help);
        $shell->run($input, $consoleOutput);
    }
Exemplo n.º 3
0
 /**
  * @param OutputInterface $output
  * @param Result $result
  */
 protected function _printResults(OutputInterface $output, ResultCollection $results)
 {
     $lastResultGroup = null;
     foreach ($results as $result) {
         if ($result->getResultGroup() != $lastResultGroup) {
             $this->writeSection($output, str_pad(strtoupper($result->getResultGroup()), 60, ' ', STR_PAD_BOTH));
         }
         if ($result->getMessage()) {
             switch ($result->getStatus()) {
                 case Result::STATUS_WARNING:
                 case Result::STATUS_ERROR:
                     $output->write('<error>' . \N98\Util\Unicode\Charset::convertInteger(self::UNICODE_CROSS_CHAR) . '</error> ');
                     break;
                 default:
                 case Result::STATUS_OK:
                     $output->write('<info>' . \N98\Util\Unicode\Charset::convertInteger(self::UNICODE_CHECKMARK_CHAR) . '</info> ');
                     break;
             }
             $output->writeln($result->getMessage());
         }
         $lastResultGroup = $result->getResultGroup();
     }
 }