add() public method

Adds a module to the collection.
public add ( Puli\Manager\Api\Module\Module $module )
$module Puli\Manager\Api\Module\Module The added module.
示例#1
0
 private function renameNonRootModule(Module $module, $newName)
 {
     $previousInstallInfo = $module->getInstallInfo();
     $installInfo = new InstallInfo($newName, $previousInstallInfo->getInstallPath());
     $installInfo->setInstallerName($previousInstallInfo->getInstallerName());
     foreach ($previousInstallInfo->getDisabledBindingUuids() as $uuid) {
         $installInfo->addDisabledBindingUuid($uuid);
     }
     $this->rootModuleFile->removeInstallInfo($module->getName());
     $this->rootModuleFile->addInstallInfo($installInfo);
     try {
         $this->jsonStorage->saveRootModuleFile($this->rootModuleFile);
     } catch (Exception $e) {
         $this->rootModuleFile->removeInstallInfo($newName);
         $this->rootModuleFile->addInstallInfo($previousInstallInfo);
         throw $e;
     }
     $this->modules->remove($module->getName());
     $this->modules->add(new Module($module->getModuleFile(), $module->getInstallPath(), $installInfo, $module->getLoadErrors()));
 }
示例#2
0
 /**
  * Returns all modules with conflicting path mappings.
  *
  * The method {@link load()} needs to be called before calling this method,
  * otherwise an exception is thrown.
  *
  * @return ModuleList The conflicting modules.
  *
  * @throws NotLoadedException If the mapping is not loaded.
  */
 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;
 }