Check if all required extensions (if any) are loaded
@param array $module
@return bool
@throws UnexpectedValueException
517157
public function checkDependenciesExtensions(array $module)
    {
        if (!empty($module['extensions'])) {

            $missing = array();

            foreach ($module['extensions'] as $extension) {
                if (!extension_loaded($extension)) {
                    $missing[] = $extension;
                }
            }

            if (!empty($missing)) {
                $error = $this->translation->text("Missing PHP extensions: @list", array('@list' => implode(',', $missing)));
                throw new UnexpectedValueException($error);
            }
        }

        return true;
    }
1076822
def is_module_loaded(module):
    """"""
    matches = re.findall('^%s[ ]+' % module, lsmod(), re.M)
    return len(matches) > 0
1051437
private function checkActivation($module)
    {
        try {
            $moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir());
            $moduleValidator->validate(false);
        } catch (\Exception $ex) {
            throw $ex;
        }

        return true;
    }
189005
public function checkModuleId($module_id)
    {
        if (!$this->module->isValidId($module_id)) {
            throw new UnexpectedValueException($this->translation->text('Invalid module ID'));
        }

        return true;
    }
98437
public static function loadScriptingModule($module)
    {
        $fullScriptPath = false;

        //  Remove any quotes from this passed in module
        $module = trim(str_replace(["'", '"'], null, $module), ' /');

        //  Check the configured script paths
        if (null === ($script = array_get(static::$libraries, $module))) {
            $script = $module;
        }

        foreach (static::$libraryPaths as $key => $path) {
            $checkScriptPath = $path . DIRECTORY_SEPARATOR . $script;

            if (is_file($checkScriptPath) && is_readable($checkScriptPath)) {
                $fullScriptPath = $checkScriptPath;
                break;
            }
        }

        if (!$script || !$fullScriptPath) {
            throw new InternalServerErrorException(
                'The module "' . $module . '" could not be found in any known locations.'
            );
        }

        return file_get_contents($fullScriptPath);
    }
841492
public function dropSchema($module)
    {			
    		$res = $this->parseSchema($module);
    		if (is_array($res['tables'])) foreach ($res['tables'] as $table) {
            $this->dbConnection->executeQuery('DROP TABLE IF EXISTS `'.$table['name'].'`');
    		}
    		if (is_array($res['types'])) foreach ($res['types'] as $type) {
            try {
                ObjectDefinition::findByTable($type['name'])->delete();
            } catch (\Exception $e) {}
    		}        
    }
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;
    }
378937
public function checkFields(string $module, array $fields = []): void
    {
        $seenFields = [];

        // Check each field one by one
        foreach ($fields as $field) {
            // Check for field duplicates
            if (in_array($field['name'], $seenFields)) {
                $this->errors[] = $module . " migration specifies field '" . $field['name'] . "' more than once";
                continue;
            }

            $seenFields[] = $field['name'];

            $type = $field['type'];
            $limit = null;
            // Matches:
            // * date, time, string, and other simple types
            // * list(something), related(Others) and other simple limits
            // * related(Vendor/Plugin.Model) and other complex limits
            // * aggregated(CsvMigrations\\Aggregator\\MaxAggregator,TableName,field_name) aggregated configuration
            if (preg_match('/^(\w+?)\(([\w\/\.\,\\\]+?)\)$/', $field['type'], $matches)) {
                $type = $matches[1];
                $limit = $matches[2];
            }

            // Field type must be valid
            if (!Utility::isValidFieldType($type)) {
                $this->errors[] = $module . " migration specifies invalid type '" . $type . "' for field  '" . $field['name'] . "'";
                continue;
            }

            switch ($type) {
                case 'related':
                    // Only check for simple modules, not the vendor/plugin ones
                    if (preg_match('/^\w+$/', $limit) && !Utility::isValidModule($limit)) {
                        $errors[] = $module . " migration relates to unknown module '$limit' in '" . $field['name'] . "' field";
                    }
                    // Documents module can be used as `files(Documents)` for a container of the uploaded files,
                    // or as `related(Documents)` as a regular module relationship.  It's often easy to overlook
                    // which one was desired.  Failing on either one is incorrect, as both are valid.  A
                    // warning is needed instead for the `related(Documents)` case instead.
                    // The only known legitimate case is in the Files, which is join table between Documents and FileStorage.
                    if (('Documents' == $limit) && ('Files' != $module)) {
                        $this->warnings[] = $module . " migration uses 'related' type for 'Documents' in '" . $field['name'] . "'. Maybe wanted 'files(Documents)'?";
                    }
                    break;
                case 'list':
                case 'money':
                case 'metric':
                    if (!Utility::isValidList($limit, $module)) {
                        $this->errors[] = $module . " migration uses unknown or empty list '$limit' in '" . $field['name'] . "' field";
                    }
                    break;
            }
        }
    }
445183
protected function _addExtensions(\OxidEsales\Eshop\Core\Module\Module $module)
    {
        $modules = $this->_removeNotUsedExtensions($this->getModulesWithExtendedClass(), $module);

        if ($module->hasExtendClass()) {
            $this->validateMetadataExtendSection($module);
            $addModules = $module->getExtensions();
            $modules = $this->_mergeModuleArrays($modules, $addModules);
        }

        $modules = $this->buildModuleChains($modules);

        $this->_saveToConfig('aModules', $modules);
    }
102830
public function getModuleDeps($module)
    {
        $module = strtolower($module);
        
        if (!isset($this->deps[$module])) {
            $map     = array();
            $deps    = array();
            $modules = $this->findModules();
    
            foreach ($modules as $name) {
                $config     = $this->getModuleDefinition($name);
                $map[$name] = isset($config['name']) ? $config['name'] : null;
            }
    
            $config = $this->getModuleDefinition($module);
            
            foreach (['require', 'require-dev'] as $key) {
                if (isset($config[$key])) {
                    foreach ($config[$key] as $composerName => $composerVersion) {
                        $moduleName = array_search($composerName, $map);
        
                        if ($moduleName !== false) {
                            $deps[$moduleName] = ltrim($composerVersion, '<>=');
                        }
                    }
                }
            }
    
            $this->deps[$module] = $deps;
        }
    
        return $this->deps[$module];
    }
478897
protected function checkDependenciesModule($module_id)
    {
        $modules = $this->module->getList();
        $validated = $this->validateDependencies($modules, true);

        if (empty($validated[$module_id]['errors'])) {
            return true;
        }

        $messages = array();
        foreach ($validated[$module_id]['errors'] as $error) {
            list($text, $arguments) = $error;
            $messages[] = $this->translation->text($text, $arguments);
        }

        throw new UnexpectedValueException(implode('<br>', $messages));
    }
85986
public static function exists($module)
	{
		if (array_key_exists($module, static::$modules))
		{
			return static::$modules[$module];
		}
		else
		{
			$paths = \Config::get('module_paths', array());

			foreach ($paths as $path)
			{
				if (is_dir($path.$module))
				{
					return $path.$module.DS;
				}
			}
		}

		return false;
	}
521565
private function isEnabled($module)
    {
        if (!array_key_exists($module, $this->enabled)) {
            throw new \InvalidArgumentException("Module '$module' cannot be enabled or disabled. Only [".implode(', ', array_keys($this->enabled)).'] can.');
        }

        return $this->enabled[$module];
    }
849296
public function has_type_handler($module, $type) {
        if (!$this->is_known_type($type)) {
            throw new coding_exception("Checking for handler for unknown type $type");
        }
        foreach ($this->types[$type]->handlers as $handler) {
            if ($handler->module == $module) {
                return true;
            }
        }
        return false;
    }
259147
public function isModuleCurrent(string $module): bool
	{
		return strpos($this->getAction(true), $module) !== false;
	}
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;
    }
470658
public function containsModules(array $modules)
    {
        foreach ($modules as $module) {
            if (!$this->modules->contains($module)) {
                return false;
            }
        }

        return true;
    }