Starts initialization, collection and registration of modules.
This prepares the manager for further requests.

@param string[]|null $modules     optional override of config: list of module FQN's
@return $this
774341
public function initialize(array $modules = null)
    {
        if ($this->initialized) return $this;

        if (is_array($modules)) {
            $this->moduleClasses = $modules;
        } else {
            $this->loadConfiguredModuleClasses();
        }

        $this->populateModuleCollection()
             ->sortModules()
             ->populateAssociatedClassIndex();

        $this->initialized = true;

        return $this;
    }
126249
protected function initModules()
    {
        $modules = null;

        if ($this->config !== null) {
            $modules = $this->config->get('modules', null);
        }

        if ($modules !== null) {
            $pathFile = $this->config->get('bootstrap')->get('path');
            $moduleName = $this->config->get('bootstrap')->get('module');
            $arrayModules = [];

            /**
             * @var $module Config
             */
            foreach ($modules as $name => $module) {
                $namespace = $module->get('namespace');
                $path = $pathFile . str_replace('\\', '/', $namespace);
                $arrayModules[$name] = [
                    'className' => $namespace . '\\' . substr($moduleName, 0, -4),
                    'path' => $path . '/' . $moduleName
                ];
            }

            $this->registerModules($arrayModules);
        }
    }
1348849
public function _initialize()
    {
        try {
            $this->driver = new RedisDriver([
                'host'     => $this->config['host'],
                'port'     => $this->config['port'],
                'database' => $this->config['database']
            ]);
        } catch (\Exception $e) {
            throw new ModuleException(
                __CLASS__,
                $e->getMessage()
            );
        }
    }
150106
function setModulesDir($modulesDir)
    {
        if (is_string($modulesDir))
            $modulesDir = array($modulesDir);

        $this->modulesDir = array_merge($this->modulesDir, $modulesDir);
        return $this;
    }
1242698
public function addModule(Module $module)
    {
        if ($this->db !== $module->getDB())
            throw new MigrationException("The DB instances should be the same");

        $name = self::normalizeModule($module->getModule());
        $this->modules[$name] = $module;
        return $this;
    }
1210480
public function loadModuleDependencies($module)
    {
        $config = $module->getConfig();
        if (isset($config['modules'])) {
            $this->loadConfig($config, $module);
        }
    }
1072275
public function initModules(Config $config)
    {
        $this->baseInitModule($config);

        $namespaces = array();
        //prepares modules configurations and modules task namespace
        foreach ($this->application->getModules() as $moduleName => $module) {
            $namespaces[$moduleName . '\Tasks'] = dirname($module['path'])
                                                        . DIRECTORY_SEPARATOR . 'tasks';
        }

        //registers module's tasks directories
        $loader = new PhalconLoader();
        $loader->registerNamespaces($namespaces, true);
        $loader->register();
    }
472116
protected function initialiseCommands()
    {
        $modules = $this->kernel->getModules();

        foreach ($modules as $module) {
            if ( ! $module instanceof ConsoleModuleInterface) {
                continue;
            }

            $module->registerCommands($this);
        }
    }
1328922
private function _setModule()
	{
		if (preg_match('/^[a-z0-9_-]+$/', $this->_requestVars[0])) {
			$this->_module = $this->_requestVars[0];
        } else {
        	$this->_module = $this->_requestVars[0] = self::DEFAULT_MODULE;
        }

        return $this;
	}
82131
public function init(array $values = [])
    {
        if ($this->app) {
            return false;
        }

        $this->app = new Application($values);

        return $this;
    }
58563
function setDependencies(\assegai\Server $server, ModuleContainer $modules)
	{
        $this->server = $server;
        $this->modules = $modules;
	}
1186629
public function build($configs)
    {
        foreach ($configs as $config) {

            $this->config = $config;

            $this->initVars();
            $this->loadColumns();

            $this->buildDataClasses();
            $this->buildMapperClasses();
            $this->generateClasses();
        }

        return $this;
    }
1213863
public function init($configurations = array())
    {
        $this->parseAndFillConfiguration($configurations);

        $this->included_directories = $this->default_include['directories'];
        $this->included_extensions = $this->default_include['extensions'];
        $this->included_patterns = $this->default_include['patterns'];

        $this->excluded_directories = $this->default_exclude['directories'];
        $this->excluded_files = $this->default_exclude['files'];
        $this->excluded_extensions = $this->default_exclude['extensions'];
        $this->excluded_patterns = $this->default_exclude['patterns'];
        $this->exclude_hidden = $this->default_exclude['hidden'];

        return $this;
    }
24096
public function setModule($module)
    {
        $layout = $this->getViewModel();
        $layout->setModule((string) $module);

        return $this;
    }
684963
protected function prepareModules(array $modules, $container)
    {
        foreach ($modules as $module) {
            $identifier = $module->name;
            if ($module->className) {
                // Fix samson.php files
                if (!class_exists($module->className)) {
                    require_once($module->pathName);
                }
                $instance = $container->get($module->className);
            } else {
                continue;
            }

            // Set composer parameters
            $instance->composerParameters = $module->composerParameters;

            // TODO: Change event signature to single approach
            // Fire core module load event
            Event::fire('core.module_loaded', [$identifier, &$instance]);

            // Signal core module configure event
            Event::signal('core.module.configure', [&$instance, $identifier]);

            if ($instance instanceof PreparableInterface) {
                // Call module preparation handler
                if (!$instance->prepare()) {
//                    throw new \Exception($identifier.' - Module preparation stage failed');
                }
            }

            $instance->parent = $this->getClassParentModule($container, get_parent_class($instance));
        }
    }
354701
public static function init() {
		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) {
			self::$instance = new Loader();
			$modules        = array_merge( self::$available_modules, apply_filters( 'themeisle_sdk_modules', [] ) );
			foreach ( $modules as $key => $module ) {
				if ( ! class_exists( 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ) ) ) {
					unset( $modules[ $key ] );
				}
			}
			self::$available_modules = $modules;
		}
	}
879839
public function registerModules(string $filePath = null)
    {
        is_file($filePath) || $filePath = App::getBasePath() . $filePath;

        if (is_file($filePath)) {
            /** @var Registry $modules */

            /** @noinspection PhpIncludeInspection */
            $modules = require_once $filePath;

            $modules = is_array($modules) ? $modules : [];

            foreach ($modules as $module) {
                IOC::resolve('Modules')->register($module);
            }

            Event::dispatch('minimal.loaded.modules', [$filePath, $modules]);
        }
    }