85 throw new Exception\InvalidPackageKeyException(
'"' .
$packageKey .
'" is not a valid package key.', 1217959511);
88 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);
91 throw new Exception\InvalidPackagePathException(sprintf(
'The package path "%s" provided for package "%s" has no trailing forward slash.',
$packagePath,
$packageKey), 1166633722);
95 $this->composerManifest = $packageManager->getComposerManifest($this->packagePath);
97 $this->createPackageMetadata($packageManager);
107 if ($extraFlags !==
null && isset($extraFlags->{
'typo3/cms'}->{
'Package'})) {
108 foreach ($extraFlags->{
'typo3/cms'}->{
'Package'} as $flagName => $flagValue) {
109 if (property_exists($this, $flagName)) {
110 $this->{$flagName} = $flagValue;
121 protected function createPackageMetaData(PackageManager $packageManager)
123 $this->packageMetaData =
new MetaData($this->getPackageKey());
124 $this->packageMetaData->setDescription($this->getValueFromComposerManifest(
'description'));
125 $this->packageMetaData->setVersion($this->getValueFromComposerManifest(
'version'));
126 $requirements = $this->getValueFromComposerManifest(
'require');
127 if ($requirements !==
null) {
128 foreach ($requirements as $requirement => $version) {
129 $packageKey = $packageManager->getPackageKeyFromComposerName($requirement);
132 if ($packageKey ===
'cms') {
133 trigger_error(
'Extension "' . $this->packageKey .
'" defines a dependency on ext:cms, which has been removed. Please remove the dependency.', E_USER_DEPRECATED);
134 $packageKey =
'core';
136 $constraint =
new MetaData\PackageConstraint(MetaData::CONSTRAINT_TYPE_DEPENDS, $packageKey);
137 $this->packageMetaData->addConstraint($constraint);
140 $suggestions = $this->getValueFromComposerManifest(
'suggest');
141 if ($suggestions !==
null) {
142 foreach ($suggestions as $suggestion => $version) {
143 $packageKey = $packageManager->getPackageKeyFromComposerName($suggestion);
144 $constraint =
new MetaData\PackageConstraint(MetaData::CONSTRAINT_TYPE_SUGGESTS, $packageKey);
145 $this->packageMetaData->addConstraint($constraint);
154 public function isPartOfFactoryDefault()
156 return $this->partOfFactoryDefault;
163 public function isPartOfMinimalUsableSystem()
165 return $this->partOfMinimalUsableSystem;
173 public function getPackageKey()
175 return $this->packageKey;
183 public function isProtected()
185 return $this->protected;
193 public function setProtected($protected)
195 $this->
protected = (bool)$protected;
203 public function getPackagePath()
205 return $this->packagePath;
214 public function getPackageMetaData()
216 return $this->packageMetaData;
225 public function getPackageReplacementKeys()
228 return (array)$this->getValueFromComposerManifest(
'replace') ?: [];
239 public function getValueFromComposerManifest($key =
null)
242 return $this->composerManifest;
245 if (isset($this->composerManifest->{$key})) {
246 $value = $this->composerManifest->{$key};