/** * Creates a new module. * * @param ModuleFile|null $moduleFile The module file or `null` if the * module file could not be loaded. * @param string $installPath The absolute install path. * @param InstallInfo|null $installInfo The install info of this module. * @param Exception[] $loadErrors The errors that happened during * loading of the module, if any. */ public function __construct(ModuleFile $moduleFile = null, $installPath, InstallInfo $installInfo = null, array $loadErrors = array()) { Assert::absoluteSystemPath($installPath); Assert::allIsInstanceOf($loadErrors, 'Exception'); // If a module name was set during installation, that name wins over // the predefined name in the puli.json file (if any) $this->name = $installInfo && null !== $installInfo->getModuleName() ? $installInfo->getModuleName() : ($moduleFile ? $moduleFile->getModuleName() : null); if (null === $this->name) { $this->name = $this->getDefaultName(); } // The path is stored both here and in the install info. While the // install info contains the path as it is stored in the install file // (i.e. relative or absolute), the install path of the module is // always an absolute path. $this->installPath = $installPath; $this->installInfo = $installInfo; $this->moduleFile = $moduleFile; $this->loadErrors = $loadErrors; if (!file_exists($installPath)) { $this->state = ModuleState::NOT_FOUND; } elseif (count($loadErrors) > 0) { $this->state = ModuleState::NOT_LOADABLE; } else { $this->state = ModuleState::ENABLED; } }
/** * Adds install info for an installed module. * * @param InstallInfo $installInfo The install info. */ public function addInstallInfo(InstallInfo $installInfo) { $this->installInfos[$installInfo->getModuleName()] = $installInfo; }