/** * Returns the package meta data object of this package. * * @return \TYPO3\Flow\Package\MetaData */ public function getPackageMetaData() { if ($this->packageMetaData === null) { $this->packageMetaData = new MetaData($this->getPackageKey()); $this->packageMetaData->setDescription($this->getComposerManifest('description')); $this->packageMetaData->setVersion($this->getComposerManifest('version')); $this->packageMetaData->setPackageType($this->getComposerManifest('type')); $requirements = $this->getComposerManifest('require'); if ($requirements !== null) { foreach ($requirements as $requirement => $version) { if ($this->packageRequirementIsComposerPackage($requirement) === false) { // Skip non-package requirements continue; } try { $packageKey = $this->packageManager->getPackageKeyFromComposerName($requirement); } catch (Exception\InvalidPackageStateException $exception) { continue; } $constraint = new MetaData\PackageConstraint(MetaDataInterface::CONSTRAINT_TYPE_DEPENDS, $packageKey); $this->packageMetaData->addConstraint($constraint); } } } return $this->packageMetaData; }
/** * Returns the package meta data object of this package. * Note that since Flow 3.1 the MetaData won't contain any constraints, * please use the composer manifest directly if you need this information. * * @return \TYPO3\Flow\Package\MetaData * @deprecated To be removed in Flow 4.0 */ public function getPackageMetaData() { if ($this->packageMetaData === null) { $this->packageMetaData = new MetaData($this->getPackageKey()); $this->packageMetaData->setDescription($this->getComposerManifest('description')); $this->packageMetaData->setVersion($this->getComposerManifest('version')); $this->packageMetaData->setPackageType($this->getComposerManifest('type')); } return $this->packageMetaData; }
/** * Create a package, given the package key * * @param string $packageKey The package key of the new package * @param \TYPO3\Flow\Package\MetaData $packageMetaData If specified, this package meta object is used for writing the Package.xml file, otherwise a rudimentary Package.xml file is created * @param string $packagesPath If specified, the package will be created in this path, otherwise the default "Application" directory is used * @param string $packageType If specified, the package type will be set, otherwise it will default to "typo3-flow-package" * @return PackageInterface The newly created package * @throws \TYPO3\Flow\Package\Exception * @throws \TYPO3\Flow\Package\Exception\PackageKeyAlreadyExistsException * @throws \TYPO3\Flow\Package\Exception\InvalidPackageKeyException * @api */ public function createPackage($packageKey, \TYPO3\Flow\Package\MetaData $packageMetaData = null, $packagesPath = null, $packageType = 'typo3-flow-package') { if (!$this->isPackageKeyValid($packageKey)) { throw new \TYPO3\Flow\Package\Exception\InvalidPackageKeyException('The package key "' . $packageKey . '" is invalid', 1220722210); } if ($this->isPackageAvailable($packageKey)) { throw new \TYPO3\Flow\Package\Exception\PackageKeyAlreadyExistsException('The package key "' . $packageKey . '" already exists', 1220722873); } if ($packagesPath === null) { if (is_array($this->settings['package']['packagesPathByType']) && isset($this->settings['package']['packagesPathByType'][$packageType])) { $packagesPath = $this->settings['package']['packagesPathByType'][$packageType]; } else { $packagesPath = 'Application'; } $packagesPath = Files::getUnixStylePath(Files::concatenatePaths(array($this->packagesBasePath, $packagesPath))); } if ($packageMetaData === null) { $packageMetaData = new MetaData($packageKey); } if ($packageMetaData->getPackageType() === null) { $packageMetaData->setPackageType($packageType); } $packagePath = Files::concatenatePaths(array($packagesPath, $packageKey)) . '/'; Files::createDirectoryRecursively($packagePath); foreach (array(PackageInterface::DIRECTORY_METADATA, PackageInterface::DIRECTORY_CLASSES, PackageInterface::DIRECTORY_CONFIGURATION, PackageInterface::DIRECTORY_DOCUMENTATION, PackageInterface::DIRECTORY_RESOURCES, PackageInterface::DIRECTORY_TESTS_UNIT, PackageInterface::DIRECTORY_TESTS_FUNCTIONAL) as $path) { Files::createDirectoryRecursively(Files::concatenatePaths(array($packagePath, $path))); } $this->writeComposerManifest($packagePath, $packageKey, $packageMetaData); $packagePath = str_replace($this->packagesBasePath, '', $packagePath); $package = $this->packageFactory->create($this->packagesBasePath, $packagePath, $packageKey, PackageInterface::DIRECTORY_CLASSES); $this->packages[$packageKey] = $package; foreach (array_keys($this->packages) as $upperCamelCasedPackageKey) { $this->packageKeys[strtolower($upperCamelCasedPackageKey)] = $upperCamelCasedPackageKey; } $this->activatePackage($packageKey); return $package; }