コード例 #1
0
 public function testScan()
 {
     $filePatterns = ['php' => '/.*\\.php$/', 'etc' => '/\\/app\\/etc\\/.*\\.xml$/', 'config' => '/\\/etc\\/(config([a-z0-9\\.]*)?|adminhtml\\/system)\\.xml$/', 'view' => '/\\/view\\/[a-z0-9A-Z\\/\\.]*\\.xml$/', 'design' => '/\\/app\\/design\\/[a-z0-9A-Z\\/\\.]*\\.xml$/'];
     $actual = $this->_model->scan($this->_testDir, $filePatterns);
     $expected = ['php' => [$this->_testDir . '/additional.php', $this->_testDir . '/app/bootstrap.php', $this->_testDir . '/app/code/Magento/SomeModule/Helper/Test.php', $this->_testDir . '/app/code/Magento/SomeModule/Model/Test.php'], 'config' => [$this->_testDir . '/app/code/Magento/SomeModule/etc/adminhtml/system.xml', $this->_testDir . '/app/code/Magento/SomeModule/etc/config.xml'], 'view' => [$this->_testDir . '/app/code/Magento/SomeModule/view/frontend/default.xml'], 'design' => [$this->_testDir . '/app/design/adminhtml/Magento/backend/layout.xml'], 'etc' => [$this->_testDir . '/app/etc/additional.xml', $this->_testDir . '/app/etc/config.xml']];
     $this->assertEquals(sort($expected['php']), sort($actual['php']), 'Incorrect php files list');
     $this->assertEquals(sort($expected['config']), sort($actual['config']), 'Incorrect config files list');
     $this->assertEquals(sort($expected['view']), sort($actual['view']), 'Incorrect view files list');
     $this->assertEquals(sort($expected['design']), sort($actual['design']), 'Incorrect design files list');
     $this->assertEquals(sort($expected['etc']), sort($actual['etc']), 'Incorrect etc files list');
 }
コード例 #2
0
 /**
  * Processes operation task
  *
  * @return void
  */
 public function doOperation()
 {
     if (array_diff(array_keys($this->data), ['filePatterns', 'path']) !== array_diff(['filePatterns', 'path'], array_keys($this->data))) {
         return;
     }
     $this->classesScanner->getList($this->data['path']);
     $files = $this->directoryScanner->scan($this->data['path'], $this->data['filePatterns']);
     $this->repositoryScanner->setUseAutoload(false);
     $repositories = $this->repositoryScanner->collectEntities($files['di']);
     foreach ($repositories as $entityName) {
         class_exists($entityName);
     }
 }
コード例 #3
0
ファイル: compiler.php プロジェクト: shabbirvividads/magento2
 $testExcludePatterns = ["#^{$rootDir}/app/code/[\\w]+/[\\w]+/Test#", "#^{$rootDir}/lib/internal/[\\w]+/[\\w]+/([\\w]+/)?Test#", "#^{$rootDir}/setup/src/Magento/Setup/Test#", "#^{$rootDir}/dev/tools/Magento/Tools/[\\w]+/Test#"];
 $fileExcludePatterns = $opt->getOption('exclude-pattern') ? [$opt->getOption('exclude-pattern')] : ['#[\\\\/]M1[\\\\/]#i'];
 $fileExcludePatterns = array_merge($fileExcludePatterns, $testExcludePatterns);
 $relationsFile = $diDir . '/relations.ser';
 $pluginDefFile = $diDir . '/plugins.ser';
 $compilationDirs = [$rootDir . '/app/code', $rootDir . '/lib/internal/Magento', $rootDir . '/dev/tools/Magento/Tools'];
 /** @var Writer\WriterInterface $logWriter Writer model for success messages */
 $logWriter = $opt->getOption('v') ? new Writer\Console() : new Writer\Quiet();
 $log = new Log($logWriter, new Writer\Console());
 $serializer = $opt->getOption('serializer') == Igbinary::NAME ? new Igbinary() : new Standard();
 AutoloaderRegistry::getAutoloader()->addPsr4('Magento\\', $generationDir . '/Magento/');
 // 1 Code generation
 // 1.1 Code scan
 $filePatterns = ['php' => '/.*\\.php$/', 'di' => '/\\/etc\\/([a-zA-Z_]*\\/di|di)\\.xml$/'];
 $codeScanDir = realpath($rootDir . '/app');
 $directoryScanner = new Scanner\DirectoryScanner();
 $files = $directoryScanner->scan($codeScanDir, $filePatterns, $fileExcludePatterns);
 $files['additional'] = [$opt->getOption('extra-classes-file')];
 $entities = [];
 $repositoryScanner = new Scanner\RepositoryScanner();
 $repositories = $repositoryScanner->collectEntities($files['di']);
 $scanner = new Scanner\CompositeScanner();
 $scanner->addChild(new Scanner\PhpScanner($log), 'php');
 $scanner->addChild(new Scanner\XmlScanner($log), 'di');
 $scanner->addChild(new Scanner\ArrayScanner(), 'additional');
 $entities = $scanner->collectEntities($files);
 $interceptorScanner = new Scanner\XmlInterceptorScanner();
 $entities['interceptors'] = $interceptorScanner->collectEntities($files['di']);
 // 1.2 Generation of Factory and Additional Classes
 $generatorIo = new \Magento\Framework\Code\Generator\Io(new \Magento\Framework\Filesystem\Driver\File(), $generationDir);
 $generator = new \Magento\Framework\Code\Generator($generatorIo, [Interceptor::ENTITY_TYPE => 'Magento\\Framework\\Interception\\Code\\Generator\\Interceptor', Proxy::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Proxy', Factory::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Factory', Mapper::ENTITY_TYPE => 'Magento\\Framework\\Api\\Code\\Generator\\Mapper', Persistor::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Persistor', Repository::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Repository', Converter::ENTITY_TYPE => 'Magento\\Framework\\ObjectManager\\Code\\Generator\\Converter', SearchResults::ENTITY_TYPE => 'Magento\\Framework\\Api\\Code\\Generator\\SearchResults', ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => 'Magento\\Framework\\Api\\Code\\Generator\\ExtensionAttributesInterfaceGenerator', ExtensionAttributesGenerator::ENTITY_TYPE => 'Magento\\Framework\\Api\\Code\\Generator\\ExtensionAttributesGenerator']);