Получает агента
@param $moduleId
@param string $name
@return array
187351
public function getAgent($moduleId, $name = '') {
        $filter = is_array($moduleId) ? $moduleId : array(
            'MODULE_ID' => $moduleId
        );

        if (!empty($name)) {
            $filter['NAME'] = $name;
        }

        return \CAgent::GetList(array(
            "MODULE_ID" => "ASC"
        ), $filter)->Fetch();
    }
1135310
public function getModuleByName($name)
    {
        $modules = $this->getModuleRepository();
        if ($modules->has($name) === false) {
            throw new RuntimeException("Module [$name] does not exists.");
        }

        return $modules->find($name);
    }
1042714
public static function getAllConfigs($modulePath, $config = [])
    {
        $configFile = $modulePath . DIRECTORY_SEPARATOR . UniModule::$configsSubdir . DIRECTORY_SEPARATOR . UniModule::$configBasefilename . '.php';
        if (is_file($configFile)) {
            $addConfig = self::includeConfigFile($configFile);
            if (!empty($addConfig)) {
                $config = ArrayHelper::merge($addConfig, $config);
                if (isset($addConfig['parentPath'])) {
                    $parentPath = Yii::getAlias($addConfig['parentPath']);
                    if (is_dir($parentPath)) $config = self::getAllConfigs($parentPath, $config);
                }
            }
        }
        return $config;
    }
439000
protected function mapsModule($moduleName, $url, $method){
        $maps= FALSE;
        foreach ($this->getModule($moduleName) as $key) {
            $maps= $this->mapsKey($key, $url, $method);
            if($maps){break;}
        }
        return $maps;
    }
804239
public function getModuleItems($nodeId)
    {
        if (isset($this->_nodeItems[$nodeId])) {
            return $this->_nodeItems[$nodeId];
        }
        
        $data = $this->getNodeData($nodeId);
        
        if (isset($data['groups'])) {
            foreach ($data['groups'] as $groupName => $groupItem) {
                // translate the group names
                try {
                    $data['groups'][$groupName]['name'] = Yii::t($data['moduleId'], $groupItem['name'], [], Yii::$app->language);
                } catch (\Exception $e) {
                    // do nothing and keep the current name inside the array
                }
                foreach ($groupItem['items'] as $groupItemKey => $groupItemEntry) {
                    if ($groupItemEntry['permissionIsRoute']) {
                        if (!Yii::$app->auth->matchRoute($this->getUserId(), $groupItemEntry['route'])) {
                            unset($data['groups'][$groupName]['items'][$groupItemKey]);
                            continue;
                        }
                    } elseif ($groupItemEntry['permissionIsApi']) {
                        if (!Yii::$app->auth->matchApi($this->getUserId(), $groupItemEntry['permissionApiEndpoint'])) {
                            unset($data['groups'][$groupName]['items'][$groupItemKey]);
                            continue;
                        }
                    } else {
                        throw new Exception('Menu item detected without permission entry');
                    }
                    try {
                        $alias = Yii::t($data['moduleId'], $data['groups'][$groupName]['items'][$groupItemKey]['alias'], [], Yii::$app->language);
                    } catch (\Exception $err) {
                        $alias = $data['groups'][$groupName]['items'][$groupItemKey]['alias'];
                    }
                    
                    // if a pool is available, the route will be modified by appending the pool param
                    $pool = AdminMenuBuilder::getOptionValue($groupItemEntry, 'pool', null);
                    if ($pool) {
                        $data['groups'][$groupName]['items'][$groupItemKey]['route'] = $data['groups'][$groupName]['items'][$groupItemKey]['route'] . '?pool='.$pool;
                    }

                    $data['groups'][$groupName]['items'][$groupItemKey]['hiddenInMenu'] = AdminMenuBuilder::getOptionValue($groupItemEntry, 'hiddenInMenu', false);
                    $data['groups'][$groupName]['items'][$groupItemKey]['pool'] = AdminMenuBuilder::getOptionValue($groupItemEntry, 'pool', null);
                    $data['groups'][$groupName]['items'][$groupItemKey]['alias'] = $alias;
                }
                
                // if there are no items for this group, unset the group from the data array
                if (count($data['groups'][$groupName]['items']) == 0) {
                    unset($data['groups'][$groupName]);
                }
            }
            
            // if there are no groups reset the array to an empty array
            if (empty($data['groups'])) {
                $data = [];
            }
        } else {
            // as we want to catch all groups and the items of the groups, if the group has no items reset the array to an empty arrray
            $data = [];
        }

        $this->_nodeItems[$nodeId] = $data;

        return $data;
    }
1120287
protected function getModule($moduleConfig)
    {
        if (!file_exists($moduleConfig)) {
            return [];
        }

        $moduleConfigContent = file_get_contents($moduleConfig);

        return Yaml::parse($moduleConfigContent);
    }
129051
public function getOptionsByModuleName($moduleName)
    {
        $moduleOptions = $this->resolveModuleOptionsByModuleName($moduleName);
        $this->validatePlugin($moduleOptions);

        return $moduleOptions;
    }
723863
public function moduleContent($moduleName)
    {
        if ($this->isAdminContext() || empty($moduleName) || count($this->getEnvOptions()) === 0 || !Yii::$app->hasModule($moduleName)) {
            return;
        }
        
        // get module
        $module = Yii::$app->getModule($moduleName);
        $module->context = 'cms';
        
        // start module reflection
        $reflection = Yii::createObject(['class' => ModuleReflection::class, 'module' => $module]);
        $reflection->suffix = $this->getEnvOption('restString');

        $args = Json::decode($this->getCfgValue('moduleActionArgs', '{}'));
        
        // if a controller has been defined we inject a custom starting route for the
        // module reflection object.
        $ctrl = $this->getCfgValue('moduleController');
        if (!empty($ctrl)) {
            $reflection->defaultRoute($ctrl, $this->getCfgValue('moduleAction', 'index'), $args);
        }
        
        if ($this->getCfgValue('strictRender')) {
            $reflection->setRequestRoute(implode("/", [$this->getCfgValue('moduleController', $module->defaultRoute), $this->getCfgValue('moduleAction', 'index')]), $args);
        } else {
            Yii::$app->request->queryParams = array_merge($reflection->getRequestRoute()['args'], Yii::$app->request->queryParams);
        }

        $response = $reflection->run();
        
        if ($response instanceof Response) {
            return Yii::$app->end(0, $response);
        }
        
        return $response;
    }
924663
public function getModule($name){
        if(isset($this->modules[$name])){
            return $this->modules[$name];
        }
        return NULL;
    }
700325
public static function findByNameCategoryId( $name, $categoryId ) {

		$optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION );

		return self::find()->where( "$optionTable.name=:name AND $optionTable.categoryId=:id", [ ':name' => $name, ':id' => $categoryId ] )->one();
	}
1024674
public function loadModule($name)
    {
        // is the module already loaded?
        if (isset($this->_modules[$name])) {
            $this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING! module with the name "'
                .$name.'" already loaded!', __FILE__, __LINE__
            );
            return false;
        }

        $classname = "Net_SmartIRC_module_$name";
        if (class_exists($classname)) {
            $this->log(SMARTIRC_DEBUG_MODULES, "DEBUG_MODULES: \"$name\" module class"
                .' exists, initializing...', __FILE__, __LINE__
            );
        } else {
            $filename = $this->_modulepath."/$name.php";
            if (!file_exists($filename)) {
                $this->log(SMARTIRC_DEBUG_MODULES, "DEBUG_MODULES: couldn't load "
                    ."module; file \"$filename\" doesn't exist", __FILE__, __LINE__
                );
                return false;
            }
            // pray that there is no parse error, it will kill us!
            include_once($filename);

            if (!class_exists($classname)) {
                $this->log(SMARTIRC_DEBUG_MODULES, "DEBUG_MODULES: class $classname"
                    ." not found in $filename, aborting...", __FILE__, __LINE__
                );
                return false;
            }

            $this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: loading module '
                ."\"$name\" from file...", __FILE__, __LINE__
            );
        }

        $methods = array_flip(get_class_methods($classname));

        if (!(isset($methods['__construct']) || isset($methods['module_init']))) {
            $this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: required method '
                .$classname.'::__construct() not found, aborting...',
                __FILE__, __LINE__
            );
            return false;
        }

        if (!(isset($methods['__destruct']) || isset($methods['module_exit']))) {
            $this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: required method '
                .$classname.'::__destruct() not found, aborting...',
                __FILE__, __LINE__
            );
            return false;
        }

        $vars = get_class_vars($classname);
        $required = array('name', 'description', 'author', 'license');

        foreach ($required as $varname) {
            if (!isset($vars[$varname])) {
                $this->log(SMARTIRC_DEBUG_NOTICE, 'NOTICE: required module'
                    ."property {$classname}::\${$varname} not found.",
                    __FILE__, __LINE__
                );
            }
        }

        // looks like the module satisfies us, so instantiate it
        if (isset($methods['module_init'])) {
            // we're using an old module_init style module
            $this->_modules[$name] = new $classname;
            $this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: calling '
                .$classname.'::module_init()', __FILE__, __LINE__
            );
            $this->_modules[$name]->module_init($this);
        } else if (func_num_args() == 1) {
            // we're using a new __construct style module, which maintains its
            // own reference to the $irc client object it's being used on
            $this->_modules[$name] = new $classname($this);
        } else
        // we're using new style AND we have args to pass to the constructor
        if (func_num_args() == 2) {
            // only one arg, so pass it as is
            $this->_modules[$name] = new $classname($this, func_get_arg(1));
        } else {
            // multiple args, so pass them in an array
            $this->_modules[$name] = new $classname($this, array_slice(func_get_args(), 1));
        }

        $this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: successfully loaded'
            ." module: $name", __FILE__, __LINE__
        );
        return $this;
    }
194439
public function listByModuleName($moduleName)
    {
        if ($this->primaryKeysSorted) {
            $this->lazySortPrimaryKeys();
        }

        return $this->map->listBySecondaryKey($moduleName);
    }
456399
public function getModule($name)
    {
        if (!isset($this->modules[$name])) {
            throw new \LogicException(sprintf('The module "%s" don\'t exists.', $name));
        }
        return $this->modules[$name];
    }
1032823
protected function _addModuleExtensions($moduleExtensions, $moduleId)
    {
        $extensions = (array) $this->getConfig()->getConfigParam('aModuleExtensions');
        $old = isset($extensions[$moduleId]) ? $extensions[$moduleId] : null;
        $old = (array) $old;
        $new = $moduleExtensions === null ? [] : array_values($moduleExtensions);
        if (is_array($moduleExtensions)) {
            $diff = $this->diff($old, $new);
            if ($diff) {
                $extensions[$moduleId] = array_values($moduleExtensions);
                $this->output->writeLn("$moduleId fixing module extensions:" . $old === null ? ' everything ' : var_export($diff, true));
                $this->_saveToConfig('aModuleExtensions', $extensions);
                $this->needCacheClear = true;
            }
        } else {
            $this->output->writeLn("$moduleId unregister module extensions");
            $this->needCacheClear = true;
            $this->_saveToConfig('aModuleExtensions', []);
        }
    }
1083463
protected function addModuleControllers($moduleControllers, $moduleId)
    {
        $this->validateModuleMetadataControllersOnActivation($moduleControllers);

        $classProviderStorage = $this->getClassProviderStorage();

        $classProviderStorage->add($moduleId, $moduleControllers);
    }
1101212
public function executeOnlyFor(array $module_names) {
	    $result = array();
	    if(HookProvider::getInstance()->isModuleOperational()){
	       $params = func_get_args();
	       array_shift($params);
    	    foreach ($module_names as $module_name) {
    	        if($module = Module::getModuleByName($module_name)) {
    	            $result[] = call_user_func_array(array($module, $this->hook_function), $params);
    	        }
    	    }
	    }
	    return $result;
	}
1080036
public static function list_course_modules($competencyid, $courseid) {
        global $DB;

        $results = $DB->get_records_sql('SELECT coursemodules.id as id
                                           FROM {' . self::TABLE . '} modcomp
                                           JOIN {course_modules} coursemodules
                                             ON modcomp.cmid = coursemodules.id
                                          WHERE modcomp.competencyid = ? AND coursemodules.course = ?',
                                          array($competencyid, $courseid));

        return array_keys($results);
    }