/** * Returns definitions collection * * @param string $path * @return DefinitionsCollection */ protected function getDefinitionsCollection($path) { $definitions = new DefinitionsCollection(); foreach ($this->classesScanner->getList($path) as $className => $constructorArguments) { $definitions->addDefinition($className, $constructorArguments); } return $definitions; }
/** * 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() { 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); } }
/** * {@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\\Tools\\Di\\Code\\Generator\\Interceptor']]); $configuration = $this->interceptionConfigurationBuilder->getInterceptionConfiguration($classesList); $generator->generateList($configuration); }
/** * 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\Code\ValidationException $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; }
/** * 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\Code\ValidationException $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; }