Beispiel #1
0
 /**
  * @param ContainerInterface $container
  * @param array $modules
  * @return array
  * @throws \Exception
  */
 public function installModules(ContainerInterface $container, array $modules = [])
 {
     foreach ($this->vendor->getVendors() as $vendor) {
         $vendorPath = $this->applicationPath->getModulesDir() . $vendor . '/';
         $vendorModules = count($modules) > 0 ? $modules : Filesystem::scandir($vendorPath);
         foreach ($vendorModules as $module) {
             $module = strtolower($module);
             if (isset($this->results[$module])) {
                 continue;
             }
             $modulePath = $vendorPath . ucfirst($module) . '/';
             $moduleConfigPath = $modulePath . 'Resources/config/module.xml';
             if (is_dir($modulePath) && is_file($moduleConfigPath)) {
                 $dependencies = $this->getModuleDependencies($moduleConfigPath);
                 if (count($dependencies) > 0) {
                     $this->installModules($container, $dependencies);
                 }
                 if ($this->installHelper->installModule($module, $container) === false) {
                     throw new \Exception("Error while installing module {$module}.");
                 }
                 $this->results[$module] = true;
             }
         }
     }
     return $this->results;
 }
Beispiel #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;
 }
Beispiel #3
0
 /**
  * Gibt ein Array mit den Abhängigkeiten zu anderen Modulen eines Moduls zurück
  *
  * @param string $moduleName
  *
  * @return array
  */
 protected function getDependencies($moduleName)
 {
     if ((bool) preg_match('=/=', $moduleName) === false) {
         foreach ($this->vendors->getVendors() as $vendor) {
             $path = $this->appPath->getModulesDir() . $vendor . '/' . ucfirst($moduleName) . '/Resources/config/module.xml';
             if (is_file($path) === true) {
                 return $this->getModuleDependencies($path);
             }
         }
     }
     return [];
 }
Beispiel #4
0
 /**
  * @throws \Exception
  */
 public function installSampleData()
 {
     foreach ($this->vendor->getVendors() as $vendor) {
         foreach (Filesystem::scandir($this->appPath->getModulesDir() . $vendor . '/') as $module) {
             $module = strtolower($module);
             $sampleDataInstallResult = $this->installHelper->installSampleData($module, $this->container, $this->container->get('core.modules.schemaHelper'));
             if ($sampleDataInstallResult === false) {
                 throw new \Exception("Error while installing module sample data.");
             }
         }
     }
 }
Beispiel #5
0
 /**
  * @param ContainerInterface $container
  * @param array $modules
  * @return array
  * @throws \Exception
  */
 public function updateModules(ContainerInterface $container, array $modules = [])
 {
     foreach ($this->vendor->getVendors() as $vendor) {
         $vendorPath = $this->applicationPath->getModulesDir() . $vendor . '/';
         $vendorModules = count($modules) > 0 ? $modules : Filesystem::scandir($vendorPath);
         foreach ($vendorModules as $module) {
             $module = strtolower($module);
             if (isset($this->results[$module])) {
                 continue;
             }
             $modulePath = $vendorPath . ucfirst($module) . '/';
             $moduleConfigPath = $modulePath . 'Resources/config/module.xml';
             if (is_dir($modulePath) && is_file($moduleConfigPath)) {
                 $dependencies = $this->getModuleDependencies($moduleConfigPath);
                 if (count($dependencies) > 0) {
                     $this->updateModules($container, $dependencies);
                 }
                 $this->results[$module] = $this->updateModule($container, $module);
             }
         }
     }
     return $this->results;
 }
Beispiel #6
0
 /**
  * Returns an alphabetically sorted array of all found ACP3 modules
  *
  * @return array
  */
 public function getAllModules()
 {
     if (empty($this->allModules)) {
         foreach ($this->vendors->getVendors() as $vendor) {
             foreach (Filesystem::scandir($this->appPath->getModulesDir() . $vendor . '/') as $module) {
                 $info = $this->getModuleInfo($module);
                 if (!empty($info)) {
                     $this->allModules[$info['name']] = $info;
                 }
             }
         }
         ksort($this->allModules);
     }
     return $this->allModules;
 }
Beispiel #7
0
 /**
  * Sets the cache for all registered languages
  *
  * @return bool
  */
 protected function saveLanguagePacksCache()
 {
     $languagePacks = [];
     foreach ($this->vendors->getVendors() as $vendors) {
         $languageFiles = glob($this->appPath->getModulesDir() . $vendors . '/*/Resources/i18n/*.xml');
         if ($languageFiles !== false) {
             foreach ($languageFiles as $file) {
                 $languagePack = $this->registerLanguagePack($file);
                 if (!empty($languagePack)) {
                     $languagePacks += $languagePack;
                 }
             }
         }
     }
     return $this->cache->save('language_packs', $languagePacks);
 }
Beispiel #8
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 [];
 }