@param EshopModuleSmartyPluginDirectories $moduleSmartyPluginDirectories

@throws EshopModuleValidationException
3983
public function validate(EshopModuleSmartyPluginDirectories $moduleSmartyPluginDirectories)
    {
        $directories = $moduleSmartyPluginDirectories->getWithFullPath();

        foreach ($directories as $directory) {
            if (!$this->doesDirectoryExist($directory)) {
                throw new EshopModuleValidationException('Smarty plugin directory does not exist ' . $directory);
            }
        }
    }
180612
private function checkForMissingDependencies($moduleName, DependsOnModule $module)
    {
        $dependencies = $this->getModuleDependencies($module);
        $configuredDependenciesCount = count($this->getConfiguredDependencies($moduleName));

        if ($configuredDependenciesCount < count($dependencies)) {
            $missingDependency = array_keys($dependencies)[$configuredDependenciesCount];

            $message = sprintf(
                "\nThis module depends on %s\n\n\n%s",
                $missingDependency,
                $this->getErrorMessageForDependency($module, $missingDependency)
            );

            throw new ModuleRequireException($moduleName, $message);
        }
    }
1349432
protected function checkHierarchyForModule(string $moduleName, array $index) : void
    {
        if ('' === $moduleName) {
            return;
        }

        //In case the module tried to fill from a previous loop that is still in the stack return.
        //this way we prevent infinit loops when 2 or more modules are referenced by themselves or by each other in a way that they produce circles.
        if (in_array($moduleName, $this->stack)) {
            return;
        }

        //add the current module in the stack.
        $this->stack[] = $moduleName;

        //In case the module is already filled with data.
        if (in_array($moduleName, $this->modulesPolpulatedWithData)) {
            return;
        }

        //checking the case that the module do not has any relations.
        if (! empty($index[$moduleName]) && is_array($index[$moduleName])) {
            foreach ($index[$moduleName] as $relatedModule) {
                $this->checkHierarchyForModule($relatedModule, $index);
            }
        }
        $this->populateDataInModule($moduleName);

        //remove the current module from the stack.
        unset($this->stack[$moduleName]);
    }
251430
public function setModuleSettings(&$config, $module, $settings)
    {
        $config['modules'][$module->getFolderContainer()][$module->getListName()] = $settings;
    }
676538
public function addModules(ServiceBusModule ...$serviceBusModules): void
    {
        foreach ($serviceBusModules as $serviceBusModule)
        {
            $this->modules->attach($serviceBusModule);
        }
    }
185090
public function handleOnModuleActivation(ModuleSetting $moduleSetting, string $moduleId, int $shopId)
    {
        if (!$this->canHandle($moduleSetting)) {
            throw new WrongModuleSettingException($moduleSetting, self::class);
        }

        foreach ($moduleSetting->getValue() as $shopModuleSettingData) {
            $shopModuleSetting = new ShopModuleSetting();
            $shopModuleSetting
                ->setShopId($shopId)
                ->setModuleId($moduleId);

            $shopModuleSetting = $this->mapDataToShopModuleSetting($shopModuleSetting, $shopModuleSettingData);

            $this->shopModuleSettingDao->save($shopModuleSetting);
        }
    }
85631
protected function doExclude($modules) {
    if ($modules) {
      $modules = (array) $modules;
      $this->excludeList = array_merge($this->excludeList, $modules);
      $this->installList = array_diff($this->installList, $modules);
    }
  }
661122
public function processModule($module)
    {
        if (!isset($this->registeredModules[$module]) || is_object($module)) {
            $this->registerModule($module);
        }
        $this->modules[$module] = $this->registeredModules[$module];
    }
994162
public function checkModuleExtensionsForIncorrectNamespaceClasses(\OxidEsales\Eshop\Core\Module\Module $module)
    {
        $incorrect = $this->getIncorrectExtensions($module);
        if (!empty($incorrect)) {
            $message = $this->prepareMessage('MODULE_METADATA_PROBLEMATIC_DATA_IN_EXTEND', $incorrect);
            throw new \OxidEsales\Eshop\Core\Exception\ModuleValidationException($message);
        }
    }
127573
protected function removeModule(): void
    {
        foreach (self::DIRECTORIES as $directory) {
            $this->remove($directory);
        }

        $this->installer->getIo()->write(
            sprintf(
                '  - Removed <comment>%s</comment> module from application',
                basename($this->packagePath)
            ),
            true
        );
    }
1078102
function loadModules($searchPaths, $maxdepth) {

		$modules = [];

		// Final all modules
		// =================

		$idx = 0; // module order index

		$knownSegments = [];

		foreach ($searchPaths as $path) {
			$loadpath = $this->syspath.'/'.$path;
			$files = $this->find_file('composer.json', $loadpath, $maxdepth);
			foreach ($files as $file) {
				$composerjson = \json_decode($this->file_get_contents($file->getRealPath()), true);
				if ($this->composer_has_cfsinfo($composerjson)) {
					$moduleName = $composerjson['name'];

					// backwards compatibility
					$moduleName = \str_replace('.', '/', $moduleName);

					$this->state['modules'][$moduleName] = [
						'idx' => null,
						'enabled' => true,
						'path' => realpath($file->getPath()),
						'namespace' => \str_replace('/', '\\', $moduleName).'\\',
						'rules' => [
							'identity' => [],
							'matches-before' => []
						]
					];

					$slashPos = \strpos($moduleName, '/');

					if ($slashPos === false || $slashPos == 0) {
						throw new \Exception('Invalid freia module name ['.$moduleName.']. The module name must have at least two segments seperated by a slash');
					}

					$mainsegment = \substr($moduleName, 0, $slashPos);

					if ( ! \in_array($mainsegment, $knownSegments)) {
						$knownSegments[] = $mainsegment;
					}

					// create entry in ordering index for rules reference
					$modules[$moduleName] = $idx += 1;

					if (isset($composerjson['extra'], $composerjson['extra']['freia'], $composerjson['extra']['freia']['rules'])) {
						$this->state['modules'][$moduleName]['rules'] = array_merge($this->state['modules'][$moduleName]['rules'], $composerjson['extra']['freia']['rules']);
						if ( ! $this->debugMode) {
							if (in_array('debug', $this->state['modules'][$moduleName]['rules']['identity'])) {
								$this->state['modules'][$moduleName]['enabled'] = false;
							}
						}
					}
				}
			}
		}

		$this->state['known-segments'] = $knownSegments;

		// Apply Stacking Rules
		// ====================

		$iteration = 0;

		do {

			// Sanity Check
			// ------------

			# it's entirely poissible for recursive rules to be applied, so we
			# need to have a stop mechanism; the system will try to function
			# even if recursion is detected; but a warning will be shown

			$iteration += 1;
			if ($iteration == $this->maxRulesIterations()) {
				$this->error_log("Exceeded maximum rule iteration count; potentially recursive module ruleset");
				throw new \Exception("Exceeded maximum iterations count while trying to apply module rules; potential module recursive rules");
			}

			// Sorter
			// ------

			$ordered = true;
			$ordered_modules = $modules;

			foreach ($this->state['modules'] as $moduleName => $module) {
				foreach ($module['rules']['matches-before'] as $target) {

					# matches-before: this module recieves idx of top
					# matching target -1 and all other modules aside from
					# this module who have idx < target idx recieve -1,
					# all entries with idx > old module idx recieve -1; if
					# target is not found in the modules or if the idx is
					# already smaller then the entire operation is skipped
					# and everyting retains their current idx

					$targetmodulename = static::firstMatchingModule(\array_keys($ordered_modules), $target);

					if ($targetmodulename !== null) {
						$target_idx = $ordered_modules[$targetmodulename];
						if ($target_idx < $ordered_modules[$module]) {

							$updated_modules = $ordered_modules;
							$old_module_idx = $updated_modules[$module];
							$updated_modules[$module] = $updated_modules[$targetmodulename] - 1;

							foreach ($ordered_modules as $k => $idx) {
								if ($idx < $target_idx && $k != $module) {
									$updated_modules[$k] = $idx - 1;
								}
								else if ($idx > $old_module_idx) {
									$updated_modules[$k] = $idx - 1;
								}
							}

							asort($updated_modules);
							$ordered_modules = $updated_modules;
							$ordered = false;
						}
					}
				}
			}

			$modules = $ordered_modules;
		}
		while ( ! $ordered);

		// Integrate Updated Order
		// =======================

		$updatedModules = [];
		foreach ($modules as $moduleName => $idx) {
			$updatedModules[$moduleName] = $this->state['modules'][$moduleName];
			$updatedModules[$moduleName]['idx'] = $idx;
		}

		$this->state['modules'] = $updatedModules;
	}
470942
public function disableModules($enabledModules)
    {
        $coreModules = $this->getCoreModules();

        foreach ($enabledModules as $moduleToDisable => $value) {
            if (isset($coreModules[$moduleToDisable])) {
                continue;
            }
            $module = $this->module->get($moduleToDisable);
            $module->disable();
        }
    }
453541
private function setLoadAfterLegacyModules(): void
    {
        static $legacy = [
            'core',
            'calendar',
            'comments',
            'faq',
            'listing',
            'news',
            'newsletter',
        ];

        $modules = array_merge($legacy, [$this->getName()]);
        sort($modules);
        $modules = array_values($modules);
        array_splice($modules, array_search($this->getName(), $modules, true));

        if (!\in_array('core', $modules, true)) {
            $modules[] = 'core';
        }

        $this->setLoadAfter($modules);
    }
1374990
public function enableModules($modules)
    {
        foreach ($modules as $moduleToEnable => $value) {
            $module = $this->module->get($moduleToEnable);
            $module->enable();
        }
    }
742369
protected function bootModuleComponents()
    {
        foreach ($this->app['modules']->enabled() as $module) {
            if ($this->moduleHasBlocks($module)) {
                $this->bootModuleBlocks($module);
            }
        }
    }
112351
public void setOldModule() {

        m_oldModule = true;
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_OLD_MODULE_IMPORTED_0));
        }
    }
758094
public function installModule($modulePath)
    {
        $module = $this->loadModule($modulePath);

        $moduleCache = new ModuleCache($module);
        $moduleInstaller = new ModuleInstaller($moduleCache);

        /** Clean all caches before module activation */
        $this->clearShopTmpFolder();

        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getInstance();
        $database->flushTableDescriptionCache();

        $cachedClassInstances = Registry::getKeys();

        if (!$moduleInstaller->activate($module)) {
            throw new Exception("Error on module installation: " . $module->getId());
        }

        foreach ($cachedClassInstances as $cachedClassInstance) {
            if (\OxidEsales\Eshop\Core\ConfigFile::class !== $cachedClassInstance) {
                Registry::set($cachedClassInstance, null);
            }
        }
        $baseClass = new \OxidEsales\Eshop\Core\Base();
        $baseClass->setSession(null);
        $baseClass->setUser(null);
        $baseClass->setAdminMode(null);

        if (method_exists($baseClass, 'setRights')) {
            $baseClass->setRights(null);
        }

        $this->clearShopTmpFolder();
    }