Load a module (if not yet) and return its instance.

@param string $module
@return mixed
540344
public function getInstance($module)
    {
        if ( ! $this->isLoaded($module))
        {
            $this->load($module);
        }

        return $this->instances[$module];
    }
349480
public function loadModule($module)
    {
        $trgtModule = $module;
        if (is_array($module) && !empty($module)) {
            $trgtModule = $module[count($module)-1];
        }

        if (!in_array($trgtModule, $this->getActiveModules())) {
            $moduleLoadFile = $_SERVER['DOCUMENT_ROOT'] . '/../config/melis.module.load.php';
            if (file_exists($moduleLoadFile)) {
                $modules = include $_SERVER['DOCUMENT_ROOT'] . '/../config/melis.module.load.php';

                $moduleCount = count($modules);
                $insertAtIdx = $moduleCount - 1;
                array_splice($modules, $insertAtIdx, 0, $module);

                // create the module.load file
                $this->createModuleLoader('config/', $modules, [], []);
            }
        }

        return $this->isModuleLoaded($trgtModule);
    }
1081419
public static function get($module, $key="", $default=""){
        $data=self::getFileConfig()[$module];
        if($data===null){
            $data=self::getModuleFromDB($module);
        }
        if($key){
            $value = $data[$key];
        }else{
            $value =$data;
        }
        if($value===null){
            $value=$default;
        }
        return $value;
    }
1192009
public function activateModule(DynamicModule $module)
    {
        if (!is_null($module)) {
            $module->setActive(true);
            return $this->registry->register($module);
        }

        return false;
    }
259147
public function isModuleCurrent(string $module): bool
	{
		return strpos($this->getAction(true), $module) !== false;
	}
481469
public function loadModule()
    {
        \BFW\Application::getInstance()
            ->getMonolog()
            ->getLogger()
            ->debug('Load module', ['name' => $this->name])
        ;
        
        $this->loadConfig();
        $this->obtainLoadInfos();

        $this->status->load = true;
    }
750535
public function addModule($module)
    {
        if ($module instanceof ModuleInterface) {
            if (in_array($module, $this->modules)) {
                throw new \InvalidArgumentException(
                    'This occurrence of '.get_class($module).' is already registered.'
                );
            }
            if ($module->getContainer() !== $this) {
                throw new \InvalidArgumentException(
                    'This occurrence of '.get_class($module).' is already registered in another module container.'
                );
            }

            $module->attachEvents();
            $this->modules[] = $module;

            return $this;
        }

        /** @var string $className */
        $className = $module;

        if (!is_subclass_of($className, $this->getModuleBaseClassName(), true)
            || !is_subclass_of($className, ModuleInterface::class)) {
            throw new \InvalidArgumentException(
                'Passed module class name needs to be a class extending '.$this->getModuleBaseClassName()
                .' and/or '.ModuleInterface::class
            );
        }

        if (isset($this->modules[$className])) {
            throw new \InvalidArgumentException(
                'Module '.$className.' is already registered.'
            );
        }

        if (!($this instanceof ModuleContainerInterface)) {
            throw new \RuntimeException(
                'Current module container uses the ModuleContainerTrait, but doesn\'t implement '
                .ModuleContainerInterface::class.', please implement it.'
            );
        }

        /** @var ModuleInterface $module */
        $module = new $className($this);
        $module->attachEvents();
        $this->modules[$className] = $module;

        return $this;
    }
460272
private function loadModule($modulePath)
    {
        $module = oxNew(\OxidEsales\Eshop\Core\Module\Module::class);
        if (!$module->loadByDir($modulePath)) {
            throw new Exception("Module not found");
        }
        return $module;
    }
211172
def _load_from_module(module):
    
    settings = OrderedDict()

    for key in dir(module):
        if key.isupper():
            settings[key] = getattr(module, key)
    return settings
95051
public function getViews($module = false)
    {
        $views = array();
        foreach ($this->getModules() as $module2) {
            foreach ($module2->getViewsOverride() as $view) {
                $views[] = $view;
            }
        }
        if ($module) {
            foreach ($module->getViews() as $view) {
                $views[] = $view;
            }
        }
        foreach ($this->getModules() as $module2) {
            if ($module2 !== $module) {
                foreach ($module2->getViews() as $view) {
                    $views[] = $view;
                }
            }
        }
        $mainModule = ModuleManager::getInstance()->getMainModule();
        if ($module != $mainModule) {
            Module::addFolder($views, $mainModule->getViews());
        }
        // Add framework views
        Module::addFolder($views, realpath(__DIR__ . '/../../..') . '/');
        Module::addFolder($views, realpath(__DIR__ . '/../..') . '/');
        Module::addFolder($views, realpath(__DIR__ . '/../..') . '/views');
        Module::addFolder($views, realpath(__DIR__ . '/../..') . '/modules');
        return $views;
    }
483688
public function getModule($id)
    {
        foreach ($this->registry->getMap() as $module) {
            if ($module['id'] == $id) {
                return $this->loadModule($module);
            }
        }
        return null;
    }
54081
public function module($module = null)
    {
        $return = null;

        // Ничего не передано - вернем текущуй модуль системы
        if (!isset($module) && isset($this->active)) {
            $return = &$this->active;
        } elseif (is_object($module)) {
            $return = &$module;
        } elseif (is_string($module)) {
            $return = $this->container->get($module);
        }

//        // Ничего не получилось вернем ошибку
        if ($return === null) {
            e('Не возможно получить модуль(##) системы', E_SAMSON_CORE_ERROR, array($module));
        }

        return $return;
    }
1331859
public function getUnloadedModules(array $modules)
    {
        $unloaded = array();

        foreach ($modules as $module) {
            if (!$this->isLoaded($module)) {
                array_push($unloaded, $module);
            }
        }

        return $unloaded;
    }
607624
public static function get($module) {
		if(self::$modules === array())
			self::initialize();

		if(!isset(self::$modules[$module]))
			return false;

		return self::$modules[$module];
	}
843501
public function getClassByModule($module): ?string
    {
        if ($module instanceof Module || $module instanceof ModuleModel) {
            return Module::findClass($module->type);
        }

        if (\is_string($module)) {
            return Module::findClass($module);
        }

        return null;
    }
33910
public static function getFields(string $module)
    {
        $modules = Modules::findFirstByName($module);

        if ($modules) {
            return self::find([
                'modules_id = ?0',
                'bind' => [$modules->id],
                'columns' => 'name, label, type'
            ]);
        }

        return null;
    }
354049
public function getModuleRenderer(Module $module)
    {
        $params = $module->getParams();

        if (!isset($params['service'])) {
            throw new \InvalidArgumentException(sprintf(
                'Module %s has no service parameter',
                $module->getId()
            ));
        }

        $id = $params['service'];

        if (!in_array($id, $this->moduleServices)) {
            throw new \InvalidArgumentException(sprintf(
                'Service %s is not a model service',
                $id
            ));
        }

        if (isset($this->modules[$module->getId()])) {
            return $this->modules[$module->getId()];
        }

        /** @var $service ModuleRendererInterface */
        $service = $this->modules[$module->getId()] = $this->container->get($id);
        $service->setModule($module);

        return $service;
    }