Validate module.

@param string $module
Module name.
@return string
Module name.

@throws \Exception
When module is not found.
504991
public function validateModule($module) {
        $missing_modules = $this->validator->getMissingModules([$module]);
        if ($missing_modules) {
            throw new \Exception(
                sprintf(
                    $this->trans(
                        'commands.module.download.messages.no-releases'
                    ),
                    $module
                )
            );
        }
        return $module;
    }
919490
public function setModule($module) {
        if (!is_string($module) || empty($module)) {
            $errMessage = "The module value must be a string and not be empty";
            throw new \InvalidArgumentException($errMessage, GeneralErrors::VALUE_IS_NOT_OF_EXPECTED_TYPE);
        }

        $this->module = $module;
    }
746110
public static function add_module( $module ) {
		if ( ! in_array( $module, self::$modules, true ) ) {
			self::$modules[] = $module;
		}
	}
666587
public static function getList(string $module) : array
    {
        $default = Configure::read('CsvMigrations.ValidateShell.module._default');
        $result = Configure::read('CsvMigrations.ValidateShell.module.' . $module);
        $result = empty($result) ? $default : $result;
        $result = empty($result['checks']) ? [] : $result['checks'];

        return $result;
    }
1363451
public function isDefaultModule($module=null)
	{
	    $mname = '';
	    if (!$module) {
	        $mname = $this->getCurrentModule()->getName();
	    } else {
	        if (is_string($module)) {
	            $mname = $module;
	        } elseif ($module instanceof Module) {
	            $mname = $module->getName();
	        }
	    }
	    
	    return $mname == $this->getDefaultModule()->getName();
	}
131817
public function getModuleName()
        {
            if (null === $this->_module) {
                $this->_module = $this->getParam($this->getModuleKey());
            }

            return $this->_module;
        }
1143174
public function removeModule($module)
    {
        if ($module instanceof ModuleInterface) {
            if (!in_array($module, $this->modules)) {
                throw new \InvalidArgumentException(
                    'This occurrence of '.get_class($module).' is not registered.'
                );
            }

            $this->modules = array_filter($this->modules, function ($instance) use ($module) {
                return $instance !== $module;
            });

            return $this;
        }

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

        if (!$this->hasModule($className)) {
            throw new \InvalidArgumentException(
                'The container doesn\'t contain a '.$className.' module'
            );
        }

        $this->modules[$className]->detachEvents();
        unset($this->modules[$className]);

        return $this;
    }
1209724
public static void validate(final Module module) {
        if (null == module) {
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
                .entity("Module cannot be null!")
                .build());
        }
        if(module.getName() == null ||
                module.getName().isEmpty()){
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
                    .entity("Module name cannot be null or empty!")
                    .build());
        }
        if(module.getVersion()== null ||
                module.getVersion().isEmpty()){
            throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
                    .entity("Module version cannot be null or empty!")
                    .build());
        }

        // Check artifacts
        for(final Artifact artifact: DataUtils.getAllArtifacts(module)){
            validate(artifact);
        }

        // Check dependencies
        for(final Dependency dependency: DataUtils.getAllDependencies(module)){
            validate(dependency.getTarget());
        }
    }
228793
public function bootstrapModule($module)
    {
        $config = Config::get('module');
        $modulePath = $config['module.path'] . DS;
        $moduleConfigDir = $config['module.config'] . DS;
        $class = '\\' . $this->getContainer()->get('app.namespace')
        . '\\' . $this->getModuleDir() . '\\' . ucfirst($module) . '\\BootStrap';

        $file = $modulePath . ucfirst($module) . DS . $moduleConfigDir . strtolower($module) . '.php';
        if (!file_exists($file)) {
            return false;
        }

        Config::set(strtolower($module) . '.config', include $file);

        return (new $class())->register($this->getContainer(), $file);
    }
168445
private function checkDeactivation($module)
    {
        $moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir());

        $modules = $moduleValidator->getModulesDependOf();

        if (\count($modules) > 0) {
            $moduleList = implode(', ', array_column($modules, 'code'));

            $message = (\count($modules) == 1)
                ? Translator::getInstance()->trans(
                    '%s has dependency to module %s. You have to deactivate this module before.'
                )
                : Translator::getInstance()->trans(
                    '%s have dependencies to module %s. You have to deactivate these modules before.'
                );

            throw new ModuleException(
                sprintf($message, $moduleList, $moduleValidator->getModuleDefinition()->getCode())
            );
        }

        return true;
    }
966001
public function canonical($module)
	{
		$module = preg_replace('/[^A-Z0-9_\.-]/i', '', $module);
		if (substr($module, 0, strlen('mod_')) != 'mod_')
		{
			$module = 'mod_' . $module;
		}
		return $module;
	}
782858
protected function get_module_name() {
        if (isset(self::$modulename)) {
            return self::$modulename;
        }
        self::$modulename = get_string('modulename', 'assign');
        return self::$modulename;
    }
937566
protected function getLoggerModuleNameForType()
    {
        $reflection = new ReflectionClass($this);

        $filename = $reflection->getFileName();
        $match    = str_contains($filename, 'app') ? [1 => 'core'] : null;

        if (!isset($match[1]) and ! preg_match("'src(.*?)src'si", $filename, $match)) {
            throw new Exception('Unable to resolve current module name.');
        }

        if (!isset($match[1])) {
            throw new Exception('Unable to resolve current module namespace.');
        }

        $reserved = [
            'components', 'modules'
        ];

       return str_contains($match[1], 'core')
           ? 'core'
           : trim(str_replace($reserved, '', $match[1]), DIRECTORY_SEPARATOR);
    }
74397
public function module(Module $module)
    {
        $vars = $this->model::generate_page($module, 'setting');
        
        return $this->makeResponse('module', $vars);
    }
343307
private function isModule(string $module) : bool
    {
        $config = (new ModuleConfig(ConfigType::MIGRATION(), $module, null, ['cacheSkip' => true]))->parse();
        $config = json_encode($config);
        if (false === $config) {
            return false;
        }
        $config = json_decode($config, true);
        if (empty($config)) {
            return false;
        }

        $config = (new ModuleConfig(ConfigType::MODULE(), $module, null, ['cacheSkip' => true]))->parse();
        if (! property_exists($config, 'table')) {
            return false;
        }
        if (! property_exists($config->table, 'type')) {
            return false;
        }

        if ('module' !== $config->table->type) {
            return false;
        }

        return true;
    }
1213807
public function validate($checkCurrentVersion = true)
    {
        if (null === $this->moduleDescriptor) {
            throw new \Exception(
                $this->trans(
                    "The %name module definition has not been initialized.",
                    [ '%name' => $this->moduleDirName ]
                )
            );
        }

        $this->checkVersion();

        if (true === $checkCurrentVersion) {
            $this->checkModuleVersion();
        }

        $this->checkModuleDependencies();
    }
912058
public function checkPhpVersion(array $module)
    {
        if (!empty($module['php'])) {

            $components = $this->getVersionComponents($module['php']);

            if (empty($components)) {
                throw new UnexpectedValueException($this->translation->text('Failed to read PHP version'));
            }

            list($operator, $number) = $components;

            if (!version_compare(PHP_VERSION, $number, $operator)) {
                $error = $this->translation->text('Requires incompatible version of @name', array('@name' => 'PHP'));
                throw new UnexpectedValueException($error);
            }
        }

        return true;
    }