/** * Retrieve the shop version * * @return string */ public function getShopVersion() { $directory = $this->_filesystem->getDirectoryRead(DirectoryList::CONFIG); $path = $directory->getAbsolutePath() . 'version.txt'; if (!$this->filesystemDriver->isExists($path)) { return false; } $version = $this->filesystemDriver->fileGetContents($path); $version = trim($version); return $version; }
/** * 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 } } } }