Find a specified module, if it is currently active.

@param string $module_name
@param bool   $include_disabled

@return ModuleInterface|null
974273
public function findByName(string $module_name, bool $include_disabled = false): ?ModuleInterface
    {
        return $this->all($include_disabled)
            ->first(static function (ModuleInterface $module) use ($module_name): bool {
                return $module->name() === $module_name;
            });
    }
130006
private function detectMode($method_name, $response, $parameter = '', $optional = '', $extra = '')
    {
        if ($response[0] === 401 && $this->connect->detect_mode) {
            $this->connect->detect_mode = false;
            $this->connect->setMode(false);
            if (!empty($extra)) {
                return $this->{$method_name}($parameter, $optional, $extra);
            } elseif (!empty($optional)) {
                return $this->{$method_name}($parameter, $optional);
            } elseif (!empty($parameter)) {
                return $this->{$method_name}($parameter);
            } else {
                return $this->{$method_name}();
            }
        }
        return false;
    }
1340816
public function getMode($include_flags = true)
    {
        $mode = $this->_mode;

        //Strip binary/text flags from mode
        if($include_flags === false) {
            $mode = strtr($mode, array('b' => '', 't' => ''));
        }

        return $mode;
    }
97022
public function inModuleList(string $item, string $moduleName, string $listName)
    {
        try {
            $items = (new ModuleConfig(ConfigType::LISTS(), $moduleName, $listName))->parseToArray();
        } catch (InvalidArgumentException $e) {
            return $e->getMessage();
        }

        /** @var mixed[]|null $config */
        $inactive = $items['items'][$item]['inactive'] ?? null;
        if ($inactive === null || $inactive === true) {
            return (string)__('Invalid list item: `{0}`', $item);
        }

        return true;
    }
1045370
public function getModuleById($moduleId)
    {
        foreach ($this->getModules() as $module) {
            if ($module->getModuleId() == $moduleId) {
                return $module;
            }
        }

        return null;
    }
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;
	}
1354398
public function getDisabledModuleClasses()
    {
        $disabledModules = $this->getDisabledModules();
        $disabledModuleClasses = [];
        if (isset($disabledModules) && is_array($disabledModules)) {
            //get all disabled module paths
            $extensions = $this->getModuleConfigParametersByKey(static::MODULE_KEY_EXTENSIONS);
            $modules = $this->getModulesWithExtendedClass();
            $modulePaths = $this->getModuleConfigParametersByKey(static::MODULE_KEY_PATHS);

            foreach ($disabledModules as $moduleId) {
                if (!array_key_exists($moduleId, $extensions)) {
                    $path = $modulePaths[$moduleId];
                    if (!isset($path)) {
                        $path = $moduleId;
                    }
                    foreach ($modules as $moduleClasses) {
                        foreach ($moduleClasses as $moduleClass) {
                            if (strpos($moduleClass, $path . "/") === 0) {
                                $disabledModuleClasses[] = $moduleClass;
                            }
                        }
                    }
                } else {
                    $disabledModuleClasses = array_merge($disabledModuleClasses, $extensions[$moduleId]);
                }
            }
        }

        return $disabledModuleClasses;
    }
707364
function info($plugin_name)
	{
		if(isset($this->plugins[$plugin_name])) return $this->plugins[$plugin_name];
		return false;
	}
734271
protected static function _find_module($name = null)
	{
		$files = array();

		if ($name)
		{
			// find a module
			foreach (\Config::get('module_paths') as $m)
			{
				$found = new \GlobIterator($m.$name.DS.\Config::get('migrations.folder').'*_*.php');
				if (count($found))
				{
					foreach($found as $file)
					{
						$files[] = $file->getPathname();
					}
					break;
				}
			}
		}
		else
		{
			// find all modules
			foreach (\Config::get('module_paths') as $m)
			{
				$found = new \GlobIterator($m.'*'.DS.\Config::get('migrations.folder').'*_*.php');
				foreach($found as $file)
				{
					$files[] = $file->getPathname();
				}
			}
		}

		return $files;
	}
1172709
public function find($name)
    {
        foreach ($this->all() as $module) {
            if ($module->getLowerName() === strtolower($name)) {
                return $module;
            }
        }

        return;
    }
259609
private static function getPhp($include_args = true)
    {
        $phpFinder = new PhpExecutableFinder();
        if (!$phpPath = $phpFinder->find($include_args)) {
            throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again');
        }

        return $phpPath;
    }
764757
public function get($module, $name, $default = false)
    {
        $this->initializeOnDemand();
        return $this->arrayConfig->get($module, $name, $default);
    }
221509
public function all(bool $include_disabled = false): Collection
    {
        return app('cache.array')->rememberForever('all_modules', function (): Collection {
            // Modules have a default status, order etc.
            // We can override these from database settings.
            $module_info = DB::table('module')
                ->get()
                ->mapWithKeys(static function (stdClass $row): array {
                    return [$row->module_name => $row];
                });

            return $this->coreModules()
                ->merge($this->customModules())
                ->map(static function (ModuleInterface $module) use ($module_info): ModuleInterface {
                    $info = $module_info->get($module->name());

                    if ($info instanceof stdClass) {
                        $module->setEnabled($info->status === 'enabled');

                        if ($module instanceof ModuleFooterInterface && $info->footer_order !== null) {
                            $module->setFooterOrder((int) $info->footer_order);
                        }

                        if ($module instanceof ModuleMenuInterface && $info->menu_order !== null) {
                            $module->setMenuOrder((int) $info->menu_order);
                        }

                        if ($module instanceof ModuleSidebarInterface && $info->sidebar_order !== null) {
                            $module->setSidebarOrder((int) $info->sidebar_order);
                        }

                        if ($module instanceof ModuleTabInterface && $info->tab_order !== null) {
                            $module->setTabOrder((int) $info->tab_order);
                        }
                    } else {
                        $module->setEnabled($module->isEnabledByDefault());

                        DB::table('module')->insert([
                            'module_name' => $module->name(),
                            'status'      => $module->isEnabled() ? 'enabled' : 'disabled',
                        ]);
                    }

                    return $module;
                });
        })->filter($this->enabledFilter($include_disabled));
    }
459019
public function getFiles($module_root_name) {
    $filepath = $this->environment->getExtensionPath('module', $module_root_name);

    //$old_dir = getcwd();
    //chdir($filepath);
    $files = scandir($filepath);

    foreach ($files as $filename) {
      $ext = substr(strrchr($filename, '.'), 1);
      if (in_array($ext, array('module', 'install', 'inc'))) {
        $module_files[] = $filepath . '/' . $filename;
      }
    }

    return $module_files;
  }
1180916
public function otherModules(bool $include_disabled = false): Collection
    {
        return $this->findByInterface(ModuleInterface::class, $include_disabled, true)
            ->filter(static function (ModuleInterface $module): bool {
                foreach (self::COMPONENTS as $interface) {
                    if ($module instanceof $interface) {
                        return false;
                    }
                }

                return true;
            });
    }
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);
    }
1258804
function(name, template_arguments) {

		var result = null;

		if (name in this._include_handlers) {

			result = this[this._include_handlers[name]](template_arguments);

		} else {

			result = this._config.includes[name];

		}

		return result;

	}