Puli\Manager\Api\Repository\PathMapping::getConflictingModules PHP Method

getConflictingModules() public method

The method {@link load()} needs to be called before calling this method, otherwise an exception is thrown.
public getConflictingModules ( ) : ModuleList
return Puli\Manager\Api\Module\ModuleList The conflicting modules.
    public function getConflictingModules()
    {
        if (null === $this->state) {
            throw new NotLoadedException('The mapping is not loaded.');
        }
        $collection = new ModuleList();
        foreach ($this->conflicts as $conflict) {
            foreach ($conflict->getMappings() as $mapping) {
                if ($this === $mapping) {
                    continue;
                }
                $collection->add($mapping->getContainingModule());
            }
        }
        return $collection;
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $rootModuleName = $this->rootModule->getName();
     $rootModuleFile = $this->rootModule->getModuleFile();
     foreach ($this->mapping->getConflictingModules() as $conflictingModule) {
         $moduleName = $conflictingModule->getName();
         if (!$rootModuleFile->hasOverriddenModule($moduleName)) {
             $rootModuleFile->addOverriddenModule($moduleName);
             $this->overriddenModules[] = $moduleName;
         }
         if (!$this->overrideGraph->hasEdge($moduleName, $rootModuleName)) {
             $this->overrideGraph->addEdge($moduleName, $rootModuleName);
             $this->addedEdgesFrom[] = $moduleName;
         }
     }
 }