/** * Constructor * * @param PackageManager $packageManager the package manager which knows this package * @param string $packageKey Key of this package * @param string $packagePath Absolute path to the location of the package's composer manifest * @throws Exception\InvalidPackageKeyException if an invalid package key was passed * @throws Exception\InvalidPackagePathException if an invalid package path was passed * @throws Exception\InvalidPackageManifestException if no composer manifest file could be found */ public function __construct(PackageManager $packageManager, $packageKey, $packagePath) { if (!$packageManager->isPackageKeyValid($packageKey)) { throw new Exception\InvalidPackageKeyException('"' . $packageKey . '" is not a valid package key.', 1217959511); } if (!(@is_dir($packagePath) || is_link($packagePath) && is_dir($packagePath))) { throw new Exception\InvalidPackagePathException(sprintf('Tried to instantiate a package object for package "%s" with a non-existing package path "%s". Either the package does not exist anymore, or the code creating this object contains an error.', $packageKey, $packagePath), 1166631890); } if (substr($packagePath, -1, 1) !== '/') { throw new Exception\InvalidPackagePathException(sprintf('The package path "%s" provided for package "%s" has no trailing forward slash.', $packagePath, $packageKey), 1166633722); } $this->packageManager = $packageManager; $this->packageKey = $packageKey; $this->packagePath = $packagePath; try { $this->composerManifest = $this->packageManager->getComposerManifest($this->packagePath); } catch (Exception\MissingPackageManifestException $exception) { if (!$this->loadExtensionEmconf()) { throw new Exception\InvalidPackageManifestException('No valid ext_emconf.php file found for package "' . $packageKey . '".', 1360403545); } } $this->loadFlagsFromComposerManifest(); }