Return configured module

@param AbstractAppMeta $appMeta
@param string          $contexts

@return AbstractModule
199140
private function getContxtualModule(AbstractAppMeta $appMeta, $contexts)
    {
        $contextsArray = array_reverse(explode('-', $contexts));
        $module = null;
        foreach ($contextsArray as $context) {
            $class = $appMeta->name . '\Module\\' . ucwords($context) . 'Module';
            if (! class_exists($class)) {
                $class = 'BEAR\Package\Context\\' . ucwords($context) . 'Module';
            }
            if (! is_a($class, AbstractModule::class, true)) {
                throw new InvalidContextException($context);
            }
            $module = new $class($module);
        }

        return $module;
    }
924663
public function getModule($name){
        if(isset($this->modules[$name])){
            return $this->modules[$name];
        }
        return NULL;
    }
799536
@Override
    public ModuleMetaData createModuleMetaData(ExtendedModuleInfo moduleInfo) throws MetaDataException {
        WebModuleInfo webModule = (WebModuleInfo) moduleInfo;
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "createModuleMetaData: " + webModule.getName() + " " + webModule.getContextRoot());
        }
        try {
            com.ibm.wsspi.adaptable.module.Container webModuleContainer = webModule.getContainer();
            WebAppConfiguration appConfig = webModuleContainer.adapt(WebAppConfiguration.class);
            String appName = appConfig.getApplicationName();
            String j2eeModuleName = appConfig.getJ2EEModuleName();
            WebModuleMetaDataImpl wmmd = (WebModuleMetaDataImpl) appConfig.getMetaData();
            wmmd.setJ2EEName(j2eeNameFactory.create(appName, j2eeModuleName, null));
            appConfig.setWebApp(createWebApp(moduleInfo, appConfig));
            return wmmd;
        }
        catch (Throwable e) {
            Throwable cause = e.getCause();
            MetaDataException m;
            if ((cause!=null) && (cause instanceof MetaDataException)) {
                m = (MetaDataException) cause;
                //don't log a FFDC here as we already logged an exception
            } else {
                m = new MetaDataException(e);
                FFDCWrapper.processException(e, getClass().getName(), "createModuleMetaData", new Object[] { webModule, this });//this throws the exception
            }
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "createModuleMetaData: " + webModule.getName() + "; " + e);
            }
            throw m;
        }
    }
1142668
public function getContextConfig()
    {
        if (empty($this->_contextConfig))
            $this->_contextConfig = Helper::getConfig('application', $this->_context);
        
        return $this->_contextConfig;
    }
70262
private function customModules(): Collection
    {
        $pattern   = Webtrees::MODULES_DIR . '*/module.php';
        $filenames = glob($pattern, GLOB_NOSORT);

        return Collection::make($filenames)
            ->filter(static function (string $filename): bool {
                // Special characters will break PHP variable names.
                // This also allows us to ignore modules called "foo.example" and "foo.disable"
                $module_name = basename(dirname($filename));

                return !Str::contains($module_name, ['.', ' ', '[', ']']) && Str::length($module_name) <= 30;
            })
            ->map(static function (string $filename): ?ModuleCustomInterface {
                try {
                    $module = self::load($filename);

                    if ($module instanceof ModuleCustomInterface) {
                        $module_name = '_' . basename(dirname($filename)) . '_';

                        $module->setName($module_name);
                    } else {
                        return null;
                    }

                    return $module;
                } catch (Throwable $ex) {
                    // It would be nice to show this error in a flash-message or similar, but the framework
                    // has not yet been initialised so we have no themes, languages, sessions, etc.
                    throw $ex;
                }
            })
            ->filter()
            ->mapWithKeys(static function (ModuleCustomInterface $module): array {
                return [$module->name() => $module];
            });
    }
1317946
private function initializeConfig(Application $app)
    {
        $config_provider = $app->make('Concrete\Core\Config\ConfigServiceProvider');
        $config_provider->register();

        /*
         * @var \Concrete\Core\Config\Repository\Repository
         */
        $config = $app->make('config');

        return $config;
    }
1116067
public function addModule($moduleName, $modulePath = null, $namespace = null, $moduleContainerClass = null, array $moduleInfo = [])
    {
        if (is_null($namespace)) {
            $namespace = 'Modules\\'.$moduleName;
        }

        $namespace = trim($namespace, '\\');

        $customModuleClass = "\\$namespace\\ModuleContainer";

        if ($moduleName == 'App') {
            $customModuleClass = $this->applicationContainerClass;
        }

        if (is_null($moduleContainerClass) or class_exists($customModuleClass)) {
            $moduleContainerClass = $customModuleClass;
        }

        if (!class_exists($moduleContainerClass)) {
            $moduleContainerClass = class_exists($this->defaultContainerClass)
                ? $this->defaultContainerClass
                : \KodiCMS\ModulesLoader\ModuleContainer::class;
        }

        $moduleContainer = new $moduleContainerClass($moduleName, $modulePath, $namespace, $moduleInfo);

        $this->registerModule($moduleContainer);

        return $this;
    }
1201502
public function getModulesConfig()
    {
        $result = [];
        foreach ($this->modules as $moduleName => $moduleConfig) {
            $className = $moduleConfig['className'];
            $module    = new $className;
            if (!$module instanceof AbstractModule) {
                $errMsg = sprintf('Class "%s" must be extended from %s', $className, AbstractModule::class);
                throw new Exception\RuntimeException($errMsg);
            }
            $config = $module->getConfig();
            $result = ArrayUtils::merge($result, $this->filterModuleConfig($config, $moduleName));
        }
        return $result;
    }
1132894
function createApp (appname, spec, cb, resourceModules) {
  var moduleNames = resourceModules
  async.parallel([ function (cb) {
    async.each(spec.agents, function (agent, cb) {
      moduleNames.push(agent.name)
      createAgent(appname, spec, agent, cb)
    }, cb)
  }, function (cb) {
    async.each(spec.crud, function (crud, cb) {
      var crudName = crud.name
      if (crudName.charAt(0) == '/') {
        crudName = crudName.substr(1)
      }
      crud.name = crudName.replace(/\//g, '_')
      moduleNames.push(crud.name)
      createCrud(appname, spec, crud, cb)
    }, cb)
  }, function (cb) {
    createTemplate(appname, 'app.js', {
      moduleNames: moduleNames,
      agents: spec.agents
    })
    cb()
  }, function (cb) {
    createTemplate(appname, 'appConfig.js', {
      moduleNames: moduleNames,
      agents: spec.agents
    })
    cb()
  } ], function (err) {
    fs.mkdir(path.join(path.resolve(appname), 'generated', 'locale'), function (response) {
      createLocale(appname)
      cb()
    })
  })
}
706373
function getAuthMod () {
    let authMod = null;
    for (const m of Object.keys(ravelInstance[coreSymbols.modules])) {
      const mod = ravelInstance[coreSymbols.modules][m];
      if (Metadata.getClassMetaValue(Object.getPrototypeOf(mod), '@authconfig', 'enabled', false)) {
        authMod = mod;
        break;
      }
    }
    if (authMod === null) {
      throw new $err.NotFound('Module annotated with @authconfig is required and was not found.');
    }

    return authMod;
  }
1340221
public function createEntityManager(Application $app)
    {
        $ems = new Pimple;

        foreach ($app['ems.options'] as $name => $options) {
            $ems[$name] = $ems->share(
                function () use ($app, $name, $options) {
                    if (false === isset($options['db'])) {
                        $options['db'] = $name;
                    }

                    if (isset($app['dbs'][$options['db']])) {
                        $em = EntityManager::create(
                            $app['dbs'][$options['db']],
                            $app['ems.config'][$name],
                            $app['dbs.event_manager'][$options['db']]
                        );
                    } else {
                        $em = EntityManager::create(
                            $app['db'],
                            $app['ems.config'][$name],
                            $app['db.event_manager']
                        );
                    }

                    if ($options['flush_on_terminate']) {
                        $app['dispatcher']->addListener(
                            SilexEvents::FINISH,
                            function () use ($em) {
                                $em->flush();
                                // @codeCoverageIgnoreStart
                            }
                            // @codeCoverageIgnoreEnd
                        );
                    }

                    return $em;
                }
            );
        }

        return $ems;
    }
153256
public function getApplicationModules()
    {
        $modules = [];

        foreach ($this->getModules() as $id => $obj) {
            if ($obj instanceof Module) {
                $modules[$id] = $obj;
            }
        }

        return $modules;
    }
415633
private function getModule($name)
    {
        if (!$this->moduleContainer->hasModule($name)) {
            throw new Exception(sprintf('«%s» module is not available.', $name));
        }

        $module = $this->moduleContainer->getModule($name);

        return $module;
    }
568405
public function newApp(string $app_type, ApplicationFactoryInterface $app_factory) : ApplicationInterface
    {
        return $app_factory->createApplication($app_type, $this->fs);
    }
30997
private static function getModuleFromDB($module){
        $data=Cache::get(md5("config_".$module));
        if(!$data){
            $config=self::get("config");
            $table=$config&&key_exists('db_table',$config)?$config['db_table']:"config";
            $module_key=$config&&key_exists('module_field',$config)?$config['module_field']:"module";
            $content=$config&&key_exists('content_field',$config)?$config['content_field']:"content";
            $data= Select::table($table)
                ->where($module_key,$module)
                ->value($content);
            Cache::set(md5("config_".$module),$data);
        }
        if($data){
            $data=json_decode($data,true);
        }
        return $data;
    }
436740
private function coreModules(): Collection
    {
        return Collection::make(self::CORE_MODULES)
            ->map(static function (string $class, string $name): ModuleInterface {
                $module = app($class);

                $module->setName($name);

                return $module;
            });
    }
160063
public function getTabRequestMeta() {
    if ($this->context === 'new') {
      return $this->entityMeta->getNewFormRequestMeta();
    } elseif ($this->context === 'grid') {
      return $this->entityMeta->getGridRequestMeta();
    } elseif ($this->context === self::CONTEXT_SEARCHPANEL) {
      return $this->entityMeta->getSearchPanelRequestMeta();
    } elseif ($this->context === self::CONTEXT_DEFAULT || $this->context === self::CONTEXT_ASSOC_LIST) {
      return $this->entityMeta->getDefaultRequestMeta();
    } else {
      throw new \InvalidArgumentException(sprintf("Context '%s' ist unbekannt",$this->context));
    }
  }