Example #1
0
 /**
  * @see vendor/symfony/src/Symfony/Component/Console/Command/Symfony\Component\Console\Command.Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->config = new Config($input->getOption('config'), null, array('allowModifications' => true));
     $this->config->setOutput($output);
     $this->config->setCommand($this);
     $this->config->setBaseDirPath($this->getBasePath());
     if ($input->getOption('no-interaction')) {
         $this->config->disableInteractivity();
     }
     Logger::setOutputInterface($output);
     if ($input->getOption('quiet')) {
         Logger::setVerbosity(Logger::VERBOSITY_NONE);
     }
     if ($input->getOption('verbose')) {
         Logger::setVerbosity(Logger::VERBOSITY_MAX);
     }
     if ($input->getOption('user-token')) {
         Logger::setToken($input->getOption('user-token'));
         $this->config->token = $input->getOption('user-token');
     }
     if ($input->getOption('php-option')) {
         $this->config->phpOptions = explode(',', $input->getOption('php-option'));
         foreach ($this->config->phpOptions as $options) {
             list($option, $value) = explode('=', $options);
             ini_set($option, $value);
         }
     }
     $results = array();
     foreach (explode(',', $input->getArgument('extensions')) as $extensionPath) {
         $extensionPath = realpath($extensionPath);
         //get vendor, name and version of extension
         $this->getExtensionAttributes($input, $extensionPath);
         $plugins = $this->config->getPlugins();
         foreach ($plugins as $name => $settings) {
             $results[$extensionPath] = 0;
             // check if plugin was defined in ini, but disabled
             if ('0' === $settings->checkEnabled) {
                 Logger::log('Skipping plugin "%s"', array($name));
                 continue;
             }
             // set path to plugin by convention
             $path = $this->getBasePath() . 'plugins' . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR;
             // load script file
             $file = $path . $name . '.php';
             if (!file_exists($file)) {
                 Logger::error('Could not find plugin "%s"', array($name), $stop = false);
                 Logger::log('Expected it at path "%s"', array($path));
                 continue;
             }
             // load default judge config for plugin execution
             $pluginConfig = $this->config;
             $customIni = $settings->ini;
             if (null !== $customIni && file_exists($customIni)) {
                 unset($settings->ini);
                 // add custom config settings, if given
                 $pluginConfig = new Config($customIni, null, array('allowModifications' => true));
                 $pluginConfig->merge($this->config);
             }
             $class = "{$name}\\{$name}";
             $plugin = new $class($pluginConfig);
             Logger::addCheck($extensionPath, $name);
             Logger::registerCheck($extensionPath, $name);
             $plugin->execute($extensionPath);
         }
         //swap logger output
         $logger = $this->config->getLogger();
         foreach ($logger as $name => $settings) {
             if ($name == 'output' && $settings === 'webservice' | $settings === 'console') {
                 Logger::setLoggerOutput($settings);
             }
             if ($name == 'user') {
                 Logger::setUser($settings);
             }
             if ($name == 'password') {
                 Logger::setPassword($settings);
             }
             if ($name == 'host') {
                 Logger::setHost($settings);
             }
         }
         Logger::printResults($extensionPath);
         $this->generateResultHtml($extensionPath);
     }
 }