public addDependency ( string $moduleName, string $dependency ) | ||
$moduleName | string | The module name. |
$dependency | string | The name of the dependency. |
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;
}
/** * {@inheritdoc} */ public function execute() { $rootModuleName = $this->rootModule->getName(); $rootModuleFile = $this->rootModule->getModuleFile(); foreach ($this->mapping->getConflictingModules() as $conflictingModule) { $moduleName = $conflictingModule->getName(); if (!$rootModuleFile->hasDependency($moduleName)) { $rootModuleFile->addDependency($moduleName); $this->overriddenModules[] = $moduleName; } if (!$this->overrideGraph->hasDependency($rootModuleName, $moduleName)) { $this->overrideGraph->addDependency($rootModuleName, $moduleName); $this->addedEdgesFrom[] = $moduleName; } } }