/** * Build Framework dependencies report * * @param string $outputPath * @return void */ protected function buildReport($outputPath) { $filePaths = $this->registrar->getPaths(ComponentRegistrar::MODULE); $filesForParse = Files::init()->getFiles($filePaths, '*'); $configFiles = Files::init()->getConfigFiles('module.xml', [], false); ServiceLocator::getFrameworkDependenciesReportBuilder()->build(['parse' => ['files_for_parse' => $filesForParse, 'config_files' => $configFiles, 'declared_namespaces' => Files::init()->getNamespaces()], 'write' => ['report_filename' => $outputPath]]); }
/** * Get all themes * * @return ThemePackage[] */ public function getThemes() { $themes = []; foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::THEME) as $key => $path) { $themes[$key] = $this->factory->create($key, $path); } return $themes; }
/** * Returns module config data and a path to the module.xml file. * * Example of data returned by generator: * <code> * [ 'vendor/module/etc/module.xml', '<xml>contents</xml>' ] * </code> * * @return \Traversable * * @author Josh Di Fabio <*****@*****.**> */ private function getModuleConfigs() { $modulePaths = $this->moduleRegistry->getPaths(ComponentRegistrar::MODULE); foreach ($modulePaths as $modulePath) { $filePath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, "{$modulePath}/etc/module.xml"); (yield [$filePath, $this->filesystemDriver->fileGetContents($filePath)]); } }
/** * Collect files in components * If $withContext is true, returns array of file objects with component context * * @param string $componentType * @param string $pattern * @param bool|false $withContext * @return array */ private function collect($componentType, $pattern, $withContext) { $files = []; foreach ($this->registrar->getPaths($componentType) as $componentName => $path) { $directoryRead = $this->readFactory->create($path); $foundFiles = $directoryRead->search($pattern); foreach ($foundFiles as $foundFile) { $foundFile = $directoryRead->getAbsolutePath($foundFile); if ($withContext) { $files[] = new ComponentFile($componentType, $componentName, $foundFile); } else { $files[] = $foundFile; } } } return $files; }
/** * Retrieve component paths and configs from composer.json files * * @return \Traversable */ public function getComponentsInfo() { $components = [\Magento\Framework\Component\ComponentRegistrar::THEME, \Magento\Framework\Component\ComponentRegistrar::MODULE]; foreach ($components as $component) { $paths = $this->registrar->getPaths($component); foreach ($paths as $name => $path) { if (!strstr($name, 'Swissup')) { continue; } $filePath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, "{$path}/composer.json"); try { $config = $this->filesystemDriver->fileGetContents($filePath); $config = $this->jsonDecoder->decode($config); $config['path'] = $path; (yield [$config['name'], $config]); } catch (\Exception $e) { // skip module } } } }