public function create($moduleName, $active = true)
    {
        $this->active[$moduleName] = $active;

        $moduleClass = $this->getModuleClass($moduleName);
        if (!class_exists($moduleClass)) {
            throw new ConfigurationException("Module $moduleName could not be found and loaded");
        }

        $config = $this->getModuleConfig($moduleName);

        if (empty($config) && !$active) {
            // For modules that are a dependency of other modules we want to skip the validation of the config.
            // This config validation is performed in \Codeception\Module::__construct().
            // Explicitly setting $config to null skips this validation.
            $config = null;
        }

        $this->modules[$moduleName] = $module = $this->di->instantiate($moduleClass, [$this, $config], false);

        if ($this->moduleHasDependencies($module)) {
            $this->injectModuleDependencies($moduleName, $module);
        }

        // If module is not active its actions should not be included in the actor class
        $actions = $active ? $this->getActionsForModule($module, $config) : [];

        foreach ($actions as $action) {
            $this->actions[$action] = $moduleName;
        };

        return $module;
    }
public function create($moduleName, $active = true)
    {
        $this->active[$moduleName] = $active;

        $moduleClass = $this->getModuleClass($moduleName);
        if (!class_exists($moduleClass)) {
            throw new ConfigurationException("Module $moduleName could not be found and loaded");
        }

        $config = $this->getModuleConfig($moduleName);

        if (empty($config) && !$active) {
            // For modules that are a dependency of other modules we want to skip the validation of the config.
            // This config validation is performed in \Codeception\Module::__construct().
            // Explicitly setting $config to null skips this validation.
            $config = null;
        }

        $this->modules[$moduleName] = $module = $this->di->instantiate($moduleClass, [$this, $config], false);

        if ($this->moduleHasDependencies($module)) {
            $this->injectModuleDependencies($moduleName, $module);
        }

        // If module is not active its actions should not be included in the actor class
        $actions = $active ? $this->getActionsForModule($module, $config) : [];

        foreach ($actions as $action) {
            $this->actions[$action] = $moduleName;
        };

        return $module;
    }
public function create ( $ moduleName , $ active = true ) { $ this -> active [ $ moduleName ] = $ active ; $ moduleClass = $ this -> getModuleClass ( $ moduleName ) ; if ( ! class_exists ( $ moduleClass ) ) { throw new ConfigurationException ( "Module $moduleName could not be found and loaded" ) ; } $ config = $ this -> getModuleConfig ( $ moduleName ) ; if ( empty ( $ config ) && ! $ active ) { // For modules that are a dependency of other modules we want to skip the validation of the config. // This config validation is performed in \Codeception\Module::__construct(). // Explicitly setting $config to null skips this validation. $ config = null ; } $ this -> modules [ $ moduleName ] = $ module = $ this -> di -> instantiate ( $ moduleClass , [ $ this , $ config ] , false ) ; if ( $ this -> moduleHasDependencies ( $ module ) ) { $ this -> injectModuleDependencies ( $ moduleName , $ module ) ; } // If module is not active its actions should not be included in the actor class $ actions = $ active ? $ this -> getActionsForModule ( $ module , $ config ) : [ ] ; foreach ( $ actions as $ action ) { $ this -> actions [ $ action ] = $ moduleName ; } ; return $ module ; }
Create a module.

@param string $moduleName
@param bool $active
@return \Codeception\Module
@throws \Codeception\Exception\ConfigurationException
@throws \Codeception\Exception\ModuleException
@throws \Codeception\Exception\ModuleRequireException
@throws \Codeception\Exception\InjectionException
Create a module .