Eva\EvaEngine\Engine::loadModules PHP Method

loadModules() public method

below events will be trigger - module:beforeLoadModule - module:afterLoadModule
public loadModules ( array $moduleSettings )
$moduleSettings array
    public function loadModules(array $moduleSettings)
    {
        $moduleManager = $this->getDI()->getModuleManager();
        if ($this->getEnvironment() == 'production') {
            $cachePrefix = $this->getAppName();
            $cacheFile = $this->getConfigPath() . "/_cache.{$cachePrefix}.modules.php";
            $moduleManager->setCacheFile($cacheFile);
        }
        $moduleManager->setDefaultPath($this->getModulesPath())->loadModules($moduleSettings, $this->getAppName());
        if ($this->getDI()->getConfig()->debug) {
            $cachePrefix = $this->getAppName();
            $this->writeCache($this->getConfigPath() . "/_debug.{$cachePrefix}.modules.php", $moduleManager->getModules());
        }
        $this->getApplication()->registerModules($moduleManager->getModules());
        //Overwirte default modulemanager
        $this->getDI()->set('moduleManager', $moduleManager);
        return $this;
    }

Usage Example

Example #1
0
<?php

require __DIR__ . '/../init_autoloader.php';
use Eva\EvaEngine\Engine;
$engine = new Engine(__DIR__ . '/..');
$engine->loadModules(include __DIR__ . '/../config/modules.' . $engine->getAppName() . '.php')->bootstrap()->run();