Register a list of modules gathered by categories
@param array $modules
@return int The number of registered modules
@throws \common_exception_InconsistentData
@throws \common_exception_InvalidArgumentType
19502
public function registerModulesByCategories(array $modules)
    {
        $count = 0;
        foreach($modules as $categoryModules) {
            if (is_array($categoryModules)) {
                $count += $this->registerModules($categoryModules);
            } else {
                throw new \common_exception_InvalidArgumentType(self::class, __FUNCTION__, 0, 'array', $categoryModules);
            }
        }
        return $count;
    }
710945
public function setCategories($categories)
    {
        foreach ($categories as $category) {
            $category->setBlog($this);
        }
        $this->categories = $categories;

        return $this;
    }
174648
public function registerModules(Application $app)
    {
        foreach ($this->getRegisteredModules() as $module) {
            $module->register($app);
        }

        return $this;
    }
37588
public static function targetConfigs(array $categories): array
    {
        $configs = [];

        foreach ($categories as $category) {
            $configs[$category] = static::targetConfig($category);
        }

        return array_filter($configs);
    }
632511
public function isModulesLoaded( $modules )
    {
        if ( $modules instanceof Traversable )
        {
            $modules = ArrayUtils::iteratorToArray( $modules );
        }

        if ( ! is_array( $modules ) )
        {
            $modules = preg_split( '/\|{1,2}/', (string) $modules );
        }

        foreach ( $modules as $module )
        {
            if ( ! is_array( $module ) )
            {
                $module = preg_split( '/&{1,2}/', (string) $module );
            }

            if ( $this->isAllModulesLoaded( $module ) )
            {
                return true;
            }
        }

        return false;
    }
1129766
function setModules($modules)
    {
        if (! is_array($modules) )
            throw new \InvalidArgumentException(sprintf(
                'Modules Must be Array list of module names; given (%s).'
                , $modules
            ));
        
        $this->modules = $modules;
    }
1270875
protected function sortModules(Collection $modules)
    {
        $index = 0;

        // Make a mapping to easily look up configured order with
        // Account for possibility of either 'module key' => [] or 'module key' format in config
        $orderMap = array_map(
            function ($key) {

                if (is_string($key)) return $key;

                if ( ! is_string($this->configModules[$key])) {
                    throw new UnexpectedValueException(
                        "cms-modules.menu.modules entry '{$key}' must be string or have a non-numeric key"
                    );
                }

                return $this->configModules[$key];
            },
            array_keys($this->configModules)
        );
        $orderMap = array_flip($orderMap);


        return $modules->sortBy(function (ModuleInterface $module) use (&$index, $orderMap) {

            // Order by configured order first, natural modules order second.
            if (count($orderMap)) {
                $primaryOrder = (int) array_get($orderMap, $module->getKey(), -2) + 1;
            } else {
                $primaryOrder = -1;
            }

            return $primaryOrder < 0 ? ++$index : (1 - 1 / $primaryOrder);
        });
    }
62810
public function setModules(array $modules)
    {
        $this->modules = array();

        foreach ($modules as $module) {
            $this->addModule($module);
        }

        return $this;
    }
404970
public function fixCategoriesIntegrityByArray(array $categorizables)
    {
        foreach ($categorizables as $categorizable) {
            if ($categorizable instanceof CategorizableInterface) {
                $this->fixCategoriesIntegrity($categorizable);
            }
        }
    }
1055882
function loadModules(array $modules)
    {
        $modules = array_diff($modules, array_keys($this->_c__loadedModules));
        if ( empty($modules) )
            // Modules are loaded
            return $this;


        // Load Enabled Modules:
        foreach($modules as $im => $vm) {
            /* @see loadModule */
            if (is_string($im) && $vm)
                # ['moduleName' => 'ModuleManager_Options_In_Any_Value_Form']
                $module = array($im => $vm);
            else
                # ['module', ..]
                $module = $vm;

            $this->loadModule($module);
        }


        ## Trigger Post Load Modules Event
        #
        $collectorPass = new DataCollectorModuleManager;
        $collectorPass->setModuleManager($this);
        $this->event()->trigger(EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD, $collectorPass);

        return $this;
    }
749176
protected function showModules(Collection $modules)
    {
        $table = [];
        $i     = 0;

        /** @var BaseModuleServiceProvider $module */
        foreach ($modules as $module) {
            $i++;

            $table[] = [
                'no'        => sprintf('%d.', $i),
                'name'      => $module->getManifest()->getName(),
                'kind'      => $module->getKind()->label(),
                'version'   => $module->getManifest()->getVersion(),
                'id'        => $module->getId(),
                'namespace' => $module->getNamespaceRoot()
            ];
        }

        $this->table($this->headers, $table);
    }
156464
public function parseModuleChains($modules)
    {
        $moduleList = oxNew(\OxidEsales\Eshop\Core\Module\ModuleList::class);
        return $moduleList->parseModuleChains($modules);
    }
870381
public function fit(array $values) : void
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Strategy must be fit with'
                . ' at least 1 value.');
        }

        $categories = array_values(array_unique($values));

        $this->categories = $categories;
        $this->k = count($categories);
    }
251669
public function register(string $module = null): void
    {
        if (!class_exists($module)) {
            throw new ClassNotFoundException($module);
        }
        $this->modules[] = new $module;
    }
1353563
protected function registerAspectModule()
    {
        if (isset($this->configure['modules'])) {
            foreach ($this->configure['modules'] as $module) {
                $this->register($module);
            }
        }
    }
1306751
private function registerInitializers(array $initializers)
    {
        foreach ($initializers as $initializer) {
            if (is_string($initializer) && class_exists($initializer)) {
                $initializer = new $initializer();
                if (! ($initializer instanceof InitializerInterface)) {
                    throw InvalidArgumentException::fromInvalidInitializer($initializer);
                }
            }
            if (is_callable($initializer)) {
                $this->initializers[] = $initializer;
            } else {
                throw InvalidArgumentException::fromInvalidInitializer($initializer);
            }
        }
    }
530958
public function isCoreModules(array $modules)
    {
        foreach ($modules as $module) {
            if (!$this->isCoreModule($module)) {
                return false;
            }
        }

        return true;
    }