Exemplo n.º 1
0
 /**
  * Retrieves list of classes for given path
  *
  * @param string $path path to dir with files
  *
  * @return array
  */
 public function getList($path)
 {
     $nameList = [];
     foreach ($this->classesScanner->getList($path) as $className) {
         try {
             if (!strpos($path, 'generation')) {
                 // validate all classes except classes in var/generation dir
                 $this->validator->validate($className);
             }
             $nameList[] = $className;
         } catch (\Magento\Framework\Exception\ValidatorException $exception) {
             $this->log->add(Log::COMPILATION_ERROR, $className, $exception->getMessage());
         } catch (\ReflectionException $e) {
             $this->log->add(Log::COMPILATION_ERROR, $className, $e->getMessage());
         }
     }
     $this->log->report();
     return $nameList;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $errors = $this->validate($input);
     if ($errors) {
         $output->writeln($errors);
         return;
     }
     $generationDir = $input->getOption(self::INPUT_KEY_GENERATION) ? $input->getOption(self::INPUT_KEY_GENERATION) : $this->directoryList->getPath(DirectoryList::GENERATION);
     $modulesExcludePatterns = $this->getModuleExcludePatterns();
     $testExcludePatterns = ["#^" . $this->directoryList->getPath(DirectoryList::SETUP) . "/[\\w]+/[\\w]+/Test#", "#^" . $this->directoryList->getRoot() . "/dev/tools/Magento/Tools/[\\w]+/Test#"];
     $librariesExcludePatterns = $this->getLibraryExcludePatterns();
     $testExcludePatterns = array_merge($testExcludePatterns, $modulesExcludePatterns, $librariesExcludePatterns);
     $fileExcludePatterns = $input->getOption('exclude-pattern') ? [$input->getOption(self::INPUT_KEY_EXCLUDE_PATTERN)] : ['#[\\\\/]M1[\\\\/]#i'];
     $fileExcludePatterns = array_merge($fileExcludePatterns, $testExcludePatterns);
     /** @var Writer\Console logWriter Writer model for success messages */
     $logWriter = new Writer\Console($output);
     $this->log = new Log($logWriter, $logWriter);
     AutoloaderRegistry::getAutoloader()->addPsr4('Magento\\', $generationDir . '/Magento/');
     // 1 Code generation
     $this->generateCode($generationDir, $fileExcludePatterns, $input);
     // 2. Compilation
     $this->compileCode($generationDir, $fileExcludePatterns, $input);
     //Reporter
     $this->log->report();
     if (!$this->log->hasError()) {
         $output->writeln('<info>On *nix systems, verify the Magento application has permissions to modify files ' . 'created by the compiler in the "var" directory. For instance, if you run the Magento application ' . 'using Apache, the owner of the files in the "var" directory should be the Apache user (example ' . 'command: "chown -R www-data:www-data <MAGENTO_ROOT>/var" where MAGENTO_ROOT is the Magento ' . 'root directory).</info>');
     }
 }