Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: implements IteratorAggregat\IteratorAggregate, implements Countabl\Countable, implements ArrayAcces\ArrayAccess
コード例 #1
0
ファイル: ArgsUtil.php プロジェクト: puli/cli
 /**
  * Returns the non-root modules selected in the console arguments.
  *
  * @param Args       $args    The console arguments
  * @param ModuleList $modules The available modules
  *
  * @return string[] The module names
  */
 public static function getModuleNamesWithoutRoot(Args $args, ModuleList $modules)
 {
     // Display all modules if "all" is set
     if ($args->isOptionSet('all')) {
         return $modules->getInstalledModuleNames();
     }
     $moduleNames = array();
     foreach ($args->getOption('module') as $moduleName) {
         $moduleNames[] = $moduleName;
     }
     return $moduleNames ?: $modules->getInstalledModuleNames();
 }
コード例 #2
0
ファイル: BindCommandHandler.php プロジェクト: puli/cli
 /**
  * Handles the "bind --delete" command.
  *
  * @param Args $args The console arguments
  *
  * @return int The status code
  */
 public function handleDelete(Args $args)
 {
     $bindingToRemove = $this->getBindingByUuidPrefix($args->getArgument('uuid'));
     if (!$bindingToRemove->getContainingModule() instanceof RootModule) {
         throw new RuntimeException(sprintf('Can only delete bindings from the module "%s".', $this->modules->getRootModuleName()));
     }
     $this->discoveryManager->removeRootBindingDescriptor($bindingToRemove->getUuid());
     return 0;
 }
コード例 #3
0
ファイル: MapCommandHandler.php プロジェクト: puli/cli
 /**
  * Handles the "puli map --delete" command.
  *
  * @param Args $args The console arguments
  *
  * @return int The status code
  */
 public function handleDelete(Args $args)
 {
     $repositoryPath = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);
     if (!$this->repoManager->hasRootPathMapping($repositoryPath)) {
         throw new RuntimeException(sprintf('The path "%s" is not mapped in the module "%s".', $repositoryPath, $this->modules->getRootModuleName()));
     }
     $this->repoManager->removeRootPathMapping($repositoryPath);
     return 0;
 }
コード例 #4
0
ファイル: TypeCommandHandler.php プロジェクト: puli/cli
 /**
  * Handles the "puli type --delete" command.
  *
  * @param Args $args The console arguments
  *
  * @return int The status code
  */
 public function handleDelete(Args $args)
 {
     $typeName = $args->getArgument('name');
     if (!$this->discoveryManager->hasRootTypeDescriptor($typeName)) {
         throw new RuntimeException(sprintf('The type "%s" does not exist in the module "%s".', $typeName, $this->modules->getRootModuleName()));
     }
     $this->discoveryManager->removeRootTypeDescriptor($typeName);
     return 0;
 }
コード例 #5
0
ファイル: ModuleManagerImpl.php プロジェクト: puli/manager
 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()));
 }
コード例 #6
0
ファイル: DiscoveryManagerImpl.php プロジェクト: puli/manager
 /**
  * Creates a tag manager.
  *
  * @param ProjectContext       $context
  * @param EditableDiscovery    $discovery
  * @param ModuleList           $modules
  * @param JsonStorage          $jsonStorage
  * @param LoggerInterface|null $logger
  */
 public function __construct(ProjectContext $context, EditableDiscovery $discovery, ModuleList $modules, JsonStorage $jsonStorage, LoggerInterface $logger = null)
 {
     $this->context = $context;
     $this->discovery = $discovery;
     $this->modules = $modules;
     $this->jsonStorage = $jsonStorage;
     $this->rootModule = $modules->getRootModule();
     $this->rootModuleFile = $context->getRootModuleFile();
     $this->logger = $logger ?: new NullLogger();
 }
コード例 #7
0
 public function __construct(RootModuleFileManager $rootModuleFileManager, ModuleList $modules)
 {
     $this->rootModuleFileManager = $rootModuleFileManager;
     $this->modules = $modules;
     $this->rootModule = $modules->getRootModule();
 }
コード例 #8
0
 /**
  * Creates a repository manager.
  *
  * @param ProjectContext     $context
  * @param EditableRepository $repo
  * @param ModuleList         $modules
  * @param JsonStorage        $jsonStorage
  */
 public function __construct(ProjectContext $context, EditableRepository $repo, ModuleList $modules, JsonStorage $jsonStorage)
 {
     $this->context = $context;
     $this->dispatcher = $context->getEventDispatcher();
     $this->repo = $repo;
     $this->config = $context->getConfig();
     $this->rootDir = $context->getRootDirectory();
     $this->rootModule = $modules->getRootModule();
     $this->rootModuleFile = $context->getRootModuleFile();
     $this->modules = $modules;
     $this->jsonStorage = $jsonStorage;
 }
コード例 #9
0
ファイル: ModuleCommandHandler.php プロジェクト: puli/cli
 /**
  * Prints modules with intermediate headers for the module states.
  *
  * @param IO         $io      The I/O
  * @param ModuleList $modules The modules to print
  * @param int[]      $states  The states to print
  */
 private function printModulesByState(IO $io, ModuleList $modules, array $states)
 {
     $printStates = count($states) > 1;
     foreach ($states as $state) {
         $filteredModules = array_filter($modules->toArray(), function (Module $module) use($state) {
             return $state === $module->getState();
         });
         if (0 === count($filteredModules)) {
             continue;
         }
         if ($printStates) {
             $this->printModuleState($io, $state);
         }
         if (ModuleState::NOT_LOADABLE === $state) {
             $this->printNotLoadableModules($io, $filteredModules, $printStates);
         } else {
             $styleTag = ModuleState::ENABLED === $state ? null : 'bad';
             $this->printModuleTable($io, $filteredModules, $styleTag, $printStates);
         }
         if ($printStates) {
             $io->writeLine('');
         }
     }
 }
コード例 #10
0
ファイル: DependencyGraph.php プロジェクト: puli/manager
 /**
  * Creates an override graph for the given modules.
  *
  * @param ModuleList $modules The modules to load.
  *
  * @return static The created override graph.
  */
 public static function forModules(ModuleList $modules)
 {
     $graph = new static($modules->getModuleNames());
     foreach ($modules as $module) {
         if (null === $module->getModuleFile()) {
             continue;
         }
         foreach ($module->getModuleFile()->getDependencies() as $dependency) {
             if ($graph->hasModuleName($dependency)) {
                 $graph->addDependency($module->getName(), $dependency);
             }
         }
     }
     // Do we have a root module?
     if (null === $modules->getRootModule()) {
         return $graph;
     }
     // Make sure we have numeric, ascending keys here
     $moduleOrder = array_values($modules->getRootModule()->getModuleFile()->getModuleOrder());
     // Each module overrides the previous one in the list
     for ($i = 1, $l = count($moduleOrder); $i < $l; ++$i) {
         $dependency = $moduleOrder[$i - 1];
         $moduleName = $moduleOrder[$i];
         if ($graph->hasModuleName($dependency)) {
             $graph->addDependency($moduleName, $dependency);
         }
     }
     return $graph;
 }
コード例 #11
0
ファイル: PathMapping.php プロジェクト: puli/manager
 private function makeAbsolute($relativePath, Module $containingModule, ModuleList $modules)
 {
     // Reference to install path of other module
     if ('@' !== $relativePath[0] || false === ($pos = strpos($relativePath, ':'))) {
         return $containingModule->getInstallPath() . '/' . $relativePath;
     }
     $refModuleName = substr($relativePath, 1, $pos - 1);
     if (!$modules->contains($refModuleName)) {
         throw new NoSuchModuleException(sprintf('The module "%s" referenced in the resource path "%s" was not ' . 'found. Maybe the module is not installed?', $refModuleName, $relativePath));
     }
     $refModule = $modules->get($refModuleName);
     return $refModule->getInstallPath() . '/' . substr($relativePath, $pos + 1);
 }