Check for missing dependencies.

@param string $moduleName
@param \Codeception\Lib\Interfaces\DependsOnModule $module
@throws \Codeception\Exception\ModuleException
@throws \Codeception\Exception\ModuleRequireException
180612
private function checkForMissingDependencies($moduleName, DependsOnModule $module)
    {
        $dependencies = $this->getModuleDependencies($module);
        $configuredDependenciesCount = count($this->getConfiguredDependencies($moduleName));

        if ($configuredDependenciesCount < count($dependencies)) {
            $missingDependency = array_keys($dependencies)[$configuredDependenciesCount];

            $message = sprintf(
                "\nThis module depends on %s\n\n\n%s",
                $missingDependency,
                $this->getErrorMessageForDependency($module, $missingDependency)
            );

            throw new ModuleRequireException($moduleName, $message);
        }
    }
648763
function(module) {
			if (!module) {
				return;
			}

			var file = fileByModules(module);
			Array.prototype.push.apply(seen, file.modules);
			file.requires.forEach(function(module) {
				// Ignore resoled modules and dependencies in own file
				if((_.indexOf(resolved, module) < 0) &&
				   (_.indexOf(file.modules, module) < 0)) {
					// Catch circular dependencies
					if(_.indexOf(seen, module) < 0) {
						resolve(module);
					}
					else {
						grunt.fail.fatal('Circular dependency detected:\n\t' +
						                 file.modules.join(', ') + ' depend on ' +
						                 module, 1);
					}
				}
			});
			Array.prototype.push.apply(resolved, file.modules);
		}
178097
public function addDependency($moduleName, $dependency)
    {
        if (!isset($this->moduleNames[$dependency])) {
            throw new RuntimeException(sprintf(
                'The module "%s" does not exist in the graph.',
                $dependency
            ));
        }

        if (!isset($this->moduleNames[$moduleName])) {
            throw new RuntimeException(sprintf(
                'The module "%s" does not exist in the graph.',
                $moduleName
            ));
        }

        if (null !== ($path = $this->getPath($dependency, $moduleName))) {
            $last = array_pop($path);

            throw new CyclicDependencyException(sprintf(
                'A cyclic dependency was discovered between the modules "%s" '.
                'and "%s". Please check the "override" keys defined in these '.
                'modules.',
                implode('", "', $path),
                $last
            ));
        }

        $this->dependencies[$moduleName][$dependency] = true;
    }
303467
function hasLoaded($moduleName)
    {
        if (!is_string($moduleName))
            throw new \InvalidArgumentException(sprintf(
                'Invalid module name, "%s".'
                , \Poirot\Std\flatten($moduleName)
            ));

        return in_array($moduleName, $this->listLoadedModules());
    }
1349432
protected function checkHierarchyForModule(string $moduleName, array $index) : void
    {
        if ('' === $moduleName) {
            return;
        }

        //In case the module tried to fill from a previous loop that is still in the stack return.
        //this way we prevent infinit loops when 2 or more modules are referenced by themselves or by each other in a way that they produce circles.
        if (in_array($moduleName, $this->stack)) {
            return;
        }

        //add the current module in the stack.
        $this->stack[] = $moduleName;

        //In case the module is already filled with data.
        if (in_array($moduleName, $this->modulesPolpulatedWithData)) {
            return;
        }

        //checking the case that the module do not has any relations.
        if (! empty($index[$moduleName]) && is_array($index[$moduleName])) {
            foreach ($index[$moduleName] as $relatedModule) {
                $this->checkHierarchyForModule($relatedModule, $index);
            }
        }
        $this->populateDataInModule($moduleName);

        //remove the current module from the stack.
        unset($this->stack[$moduleName]);
    }
97766
private static function loadModule(string $division, string $moduleName)
    {
        $mPath = $moduleName . '/' . ($division === '' ? 'primary/' : $division . '/');
        $mName = ucfirst($moduleName) . ucfirst($division);

        $fileName = MODULES . $mPath . $mName . 'ViewsController.php';

        if ( ! file_exists($fileName)) {
            throw new NotFoundException("Can't load module: file '$fileName' does not exists.");
        }

        /** @noinspection PhpIncludeInspection */
        require_once $fileName;
    }
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;
    }
645921
public function moduleRequirement(array $module)
    {
        // TODO: Module dependencies should also be checked
        // for unmet requirements recursively.
        $fail = false;
        foreach ($module as $module_name) {
            module_load_install($module_name);
            if ($requirements = \Drupal::moduleHandler()->invoke($module_name, 'requirements', ['install'])) {
                foreach ($requirements as $requirement) {
                    if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
                        $this->getIo()->info("Module '{$module_name}' cannot be installed: {$requirement['title']} | {$requirement['value']}");
                        $fail = true;
                    }
                }
            }
        }
        if ($fail) {
            throw new \Exception('Some module install requirements are not met.');
        }
    }
796577
private function getConfiguredDependencies($moduleName)
    {
        $config = $this->getModuleConfig($moduleName);

        if (!isset($config['depends'])) {
            return [];
        }

        return is_array($config['depends']) ? $config['depends'] : [$config['depends']];
    }
40494
protected function installModule(string $moduleName)
    {
        if (!isset($this->listToInstall[$moduleName])) {
            return;
        }
        
        $this->displayMsgNLInCli(' > Read for module '.$moduleName);
        
        $module         = $this->listToInstall[$moduleName];
        $installScripts = $module->getSourceInstallScript();
        
        if (empty($installScripts) || $installScripts === false) {
            $this->displayMsgNLInCli(' >> No script to run.');
            return;
        }
        
        if (!is_array($installScripts)) {
            $installScripts = [$installScripts];
        }
        
        foreach ($installScripts as $scriptPath) {
            $module->runInstallScript($scriptPath);
        }
    }
1225191
function byModule($moduleName)
    {
        if (!$this->hasLoaded($moduleName))
            $this->loadModule($moduleName);

        return $this->_c__loadedModules[$moduleName];
    }
1207130
public function getInstallInfo($moduleName)
    {
        if (!isset($this->installInfos[$moduleName])) {
            throw new NoSuchModuleException(sprintf(
                'Could not get install info: The module "%s" is not installed.',
                $moduleName
            ));
        }

        return $this->installInfos[$moduleName];
    }
1152550
final protected static function checkDependencies(string $dependencyClassName, string $dependencyPackageName)
    {
        if (!class_exists($dependencyClassName)) {
            throw new MissingDependencyException(
                sprintf(
                    'Class "%s" does not exist, please install package "%s"',
                    $dependencyClassName,
                    $dependencyPackageName
                )
            );
        }
    }
1236048
private function getModuleDependencies(DependsOnModule $module)
    {
        $depends = $module->_depends();

        if (!$depends) {
            return [];
        }

        if (!is_array($depends)) {
            $message = sprintf("Method _depends of module '%s' must return an array", get_class($module));
            throw new ModuleException($module, $message);
        }

        return $depends;
    }
760750
public function getDependencies($moduleName, $convertPackageNameToNamespace = true)
    {
        $modulePath = $this->getModulePath($moduleName);
        $dependencies = [];

        if ($modulePath) {

            $defaultDependencies = ['melis-core'];
            $dependencies = $defaultDependencies;
            $composerPossiblePath = [$modulePath . '/composer.json'];
            $composerFile = null;

            // search for the composer.json file
            foreach ($composerPossiblePath as $file) {
                if (file_exists($file)) {
                    $composerFile = file_get_contents($file);
                }
            }

            // if composer.json is found
            if ($composerFile) {

                $composer = json_decode($composerFile, true);
                $requires = isset($composer['require']) ? $composer['require'] : null;
                if ($requires) {
                    $requires = array_map(function ($a) {
                        // remove melisplatform prefix
                        return str_replace(['melisplatform/', ' '], '', trim($a));
                    }, array_keys($requires));

                    $dependencies = $requires;
                }
            }

            if ($convertPackageNameToNamespace) {
                $tmpDependencies = [];
                $toolSvc = $this->getServiceLocator()->get('MelisCoreTool');

                foreach ($dependencies as $dependency) {
                    $tmpDependencies[] = ucfirst($toolSvc->convertToNormalFunction($dependency));
                }

                $dependencies = $tmpDependencies;
            }
        }

        return $dependencies;
    }
306801
def add_dependencies(self, module):
        

        if module in self._processed_modules:
            return None

        if hasattr(module, "__name__"):
            mn = module.__name__
        else:
            mn = '<unknown>'

        _debug.debug("add_dependencies:module=%s", module)

        # If the module in which the class/function is defined is __main__, don't add it. Just add its dependencies.
        if mn == "__main__":
            self._processed_modules.add(module)

        # add the module as a dependency
        elif not self._add_dependency(module, mn):
            _debug.debug("add_dependencies:not added:module=%s", mn)
            return None

        _debug.debug("add_dependencies:ADDED:module=%s", mn)

        # recursively get the module's imports and add those as dependencies
        for dm in self._find_dependent_modules(module):
            _debug.debug("add_dependencies:adding dependent module %s for %s", dm, mn)
            self.add_dependencies(dm)
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));
    }