19 private $componentRegistrar;
24 private $readDirFactory;
29 private $packageNameToFullPathMap = [];
49 $this->readDirFactory = $readDirFactory;
62 $themePath = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $themePath);
63 $themeDir = $this->readDirFactory->create($themePath);
64 if ($themeDir->isExist(
'composer.json')) {
66 $themeFile = $themeDir->readFile(
'composer.json');
68 $rawData = $this->serializer->unserialize($themeFile);
70 return isset($rawData[
'name']) ? $rawData[
'name'] :
'';
83 if (empty($this->packageNameToFullPathMap)) {
84 $this->initializeMap();
86 return isset($this->packageNameToFullPathMap[$packageName])
87 ? $this->packageNameToFullPathMap[$packageName] :
'';
95 private function initializeMap()
97 $themePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::THEME);
99 foreach ($themePaths as $fullThemePath => $themeDir) {
100 $themeDirRead = $this->readDirFactory->create($themeDir);
101 if ($themeDirRead->isExist(
'composer.json')) {
102 $rawData = $this->serializer->unserialize($themeDirRead->readFile(
'composer.json'));
103 if (isset($rawData[
'name'])) {
104 $this->packageNameToFullPathMap[$rawData[
'name']] = $fullThemePath;
__construct(ComponentRegistrar $componentRegistrar, ReadFactory $readDirFactory, \Magento\Framework\Serialize\Serializer\Json $serializer=null)
getPackageName($themePath)
getFullThemePath($packageName)