示例#1
0
 /**
  * @return array
  */
 protected function getAvailableDesigns()
 {
     $designs = [];
     $path = $this->appPath->getDesignRootPathInternal();
     $directories = Core\Filesystem::scandir($path);
     foreach ($directories as $directory) {
         $designInfo = $this->xml->parseXmlFile($path . $directory . '/info.xml', '/design');
         if (!empty($designInfo)) {
             $designs[] = array_merge($designInfo, ['selected' => $this->config->getSettings(Schema::MODULE_NAME)['design'] === $directory ? 1 : 0, 'dir' => $directory]);
         }
     }
     return $designs;
 }
示例#2
0
 /**
  * @param string $modulePath
  * @param string $designPath
  * @param string $dir
  * @param string $file
  *
  * @return string
  */
 private function resolveAssetPath($modulePath, $designPath, $dir, $file)
 {
     if ($this->designAssetsPath === null) {
         $this->designAssetsPath = $this->appPath->getDesignPathInternal();
     }
     $assetPath = '';
     $designAssetPath = $this->designAssetsPath . $designPath . $dir . $file;
     // A theme has overridden a static asset of a module
     if (is_file($designAssetPath) === true) {
         $assetPath = $designAssetPath;
     } else {
         $designInfo = $this->xml->parseXmlFile($this->designAssetsPath . '/info.xml', '/design');
         // Recursively iterate over the nested themes
         if (!empty($designInfo['parent'])) {
             $this->designAssetsPath = $this->appPath->getDesignRootPathInternal() . $designInfo['parent'] . '/';
             $assetPath = $this->getStaticAssetPath($modulePath, $designPath, $dir, $file);
             $this->designAssetsPath = $this->appPath->getDesignPathInternal();
             return $assetPath;
         }
         // No overrides have been found -> iterate over all possible module namespaces
         foreach (array_reverse($this->vendors->getVendors()) as $vendor) {
             $moduleAssetPath = $this->appPath->getModulesDir() . $vendor . '/' . $modulePath . $dir . $file;
             if (is_file($moduleAssetPath) === true) {
                 $assetPath = $moduleAssetPath;
                 break;
             }
         }
     }
     $systemAssetPath = $this->appPath->getModulesDir() . $modulePath . $dir . $file;
     $this->cachedPaths[$systemAssetPath] = $assetPath;
     $this->newAssetPathsAdded = true;
     return $assetPath;
 }
示例#3
0
 /**
  * @param string $moduleDirectory
  *
  * @return array
  */
 protected function fetchModuleInfo($moduleDirectory)
 {
     $vendors = array_reverse($this->vendors->getVendors());
     // Reverse the order of the array -> search module customizations first, then 3rd party modules, then core modules
     foreach ($vendors as $vendor) {
         $path = $this->appPath->getModulesDir() . $vendor . '/' . $moduleDirectory . '/Resources/config/module.xml';
         if (is_file($path) === true) {
             $moduleInfo = $this->xml->parseXmlFile($path, 'info');
             if (!empty($moduleInfo)) {
                 $moduleName = strtolower($moduleDirectory);
                 $moduleInfoDb = $this->systemModuleRepository->getInfoByModuleName($moduleName);
                 return ['id' => !empty($moduleInfoDb) ? $moduleInfoDb['id'] : 0, 'dir' => $moduleDirectory, 'installed' => !empty($moduleInfoDb), 'active' => !empty($moduleInfoDb) && $moduleInfoDb['active'] == 1, 'schema_version' => !empty($moduleInfoDb) ? (int) $moduleInfoDb['version'] : 0, 'description' => $this->getModuleDescription($moduleInfo, $moduleName), 'author' => $moduleInfo['author'], 'version' => $moduleInfo['version'], 'name' => $this->getModuleName($moduleInfo, $moduleName), 'categories' => isset($moduleInfo['categories']), 'protected' => isset($moduleInfo['protected']), 'dependencies' => $this->getModuleDependencies($path)];
             }
         }
     }
     return [];
 }