/** * {@inheritdoc} */ public function doOperation() { if (empty($this->data)) { return; } $this->interceptionConfigurationBuilder->addAreaCode(App\Area::AREA_GLOBAL); foreach ($this->areaList->getCodes() as $areaCode) { $this->interceptionConfigurationBuilder->addAreaCode($areaCode); } $classesList = []; foreach ($this->data['intercepted_paths'] as $path) { $classesList = array_merge($classesList, $this->classesScanner->getList($path)); } $generatorIo = new \Magento\Framework\Code\Generator\Io( new \Magento\Framework\Filesystem\Driver\File(), $this->data['path_to_store'] ); $generator = $this->generatorFactory->create( [ 'ioObject' => $generatorIo, 'generatedEntities' => [ Interceptor::ENTITY_TYPE => 'Magento\Setup\Module\Di\Code\Generator\Interceptor', ] ] ); $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration($classesList); $generator->generateList($configuration); }
public function testGetList() { $pathToScan = str_replace('\\', '/', realpath(__DIR__ . '/../../') . '/_files/app/code/Magento/SomeModule'); $actual = $this->model->getList($pathToScan); $this->assertTrue(is_array($actual)); $this->assertCount(5, $actual); }
/** * Retrieves list of classes for given path * * @param string $path path to dir with files * * @return array * @throws FileSystemException */ public function getList($path) { $classes = []; foreach ($this->classesScanner->getList($path) as $className) { $classes[$className] = $this->classReaderDecorator->getConstructor($className); } return $classes; }
/** * {@inheritdoc} */ public function doOperation() { if (empty($this->data)) { return; } foreach ($this->data as $path) { $this->classesScanner->getList($path); } }
/** * Processes operation task * * @return void */ public function doOperation() { foreach ($this->data['paths'] as $path) { $this->classesScanner->getList($path); } $this->repositoryScanner->setUseAutoload(false); $files = $this->configurationScanner->scan('di.xml'); $repositories = $this->repositoryScanner->collectEntities($files); foreach ($repositories as $entityName) { class_exists($entityName); } }
/** * {@inheritdoc} */ public function doOperation() { if (empty($this->data)) { return; } foreach ($this->data as $paths) { if (!is_array($paths)) { $paths = (array) $paths; } foreach ($paths as $path) { $this->classesScanner->getList($path); } } }
/** * 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']); $this->repositoryScanner->setUseAutoload(false); $files = $this->directoryScanner->scan($this->data['path'], $this->data['filePatterns']); $repositories = $this->repositoryScanner->collectEntities($files['di']); foreach ($repositories as $entityName) { class_exists($entityName); } }
/** * Retrieves list of classes for given path * * @param string $path path to dir with files * * @return array */ public function getList($path) { foreach ($this->classesScanner->getList($path) as $className) { $this->current = $className; // for errorHandler function try { if ($path != $this->generationDir) { // validate all classes except classes in generation dir $this->validator->validate($className); } $this->relations[$className] = $this->classReader->getParents($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()); } } return $this->relations; }
/** * 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} */ public function doOperation() { if (array_diff(array_keys($this->data), ['filePatterns', 'paths', 'excludePatterns']) !== array_diff(['filePatterns', 'paths', 'excludePatterns'], array_keys($this->data))) { return; } foreach ($this->data['paths'] as $paths) { if (!is_array($paths)) { $paths = (array) $paths; } $files = []; foreach ($paths as $path) { $this->classesScanner->getList($path); $files = array_merge_recursive($files, $this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns'])); } $entities = $this->phpScanner->collectEntities($files['php']); foreach ($entities as $entityName) { class_exists($entityName); } } }