/**
  * Generate a site package and fill it with boilerplate data.
  *
  * @param string $packageKey
  * @param string $siteName
  * @return array
  */
 public function generateSitePackage($packageKey, $siteName)
 {
     $packageMetaData = new MetaData($packageKey);
     $packageMetaData->addConstraint(new PackageConstraint(MetaDataInterface::CONSTRAINT_TYPE_DEPENDS, 'TYPO3.Neos'));
     $packageMetaData->addConstraint(new PackageConstraint(MetaDataInterface::CONSTRAINT_TYPE_DEPENDS, 'TYPO3.Neos.NodeTypes'));
     $packageMetaData->addConstraint(new PackageConstraint(MetaDataInterface::CONSTRAINT_TYPE_SUGGESTS, 'TYPO3.Neos.Seo'));
     $this->packageManager->createPackage($packageKey, $packageMetaData, null, 'typo3-flow-site');
     $this->generateSitesXml($packageKey, $siteName);
     $this->generateSitesTypoScript($packageKey, $siteName);
     $this->generateSitesTemplate($packageKey, $siteName);
     $this->generateNodeTypesConfiguration($packageKey);
     $this->generateAdditionalFolders($packageKey);
     return $this->generatedFiles;
 }
 /**
  * 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;
 }
示例#4
0
 /**
  * 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'));
         $requirements = $this->getComposerManifest('require');
         if ($requirements !== NULL) {
             foreach ($requirements as $requirement => $version) {
                 if ($this->packageRequirementIsComposerPackage($requirement) === FALSE) {
                     // Skip non-package requirements
                     continue;
                 }
                 $packageKey = $this->packageManager->getPackageKeyFromComposerName($requirement);
                 $constraint = new MetaData\PackageConstraint(MetaDataInterface::CONSTRAINT_TYPE_DEPENDS, $packageKey);
                 $this->packageMetaData->addConstraint($constraint);
             }
         }
     }
     return $this->packageMetaData;
 }
 /**
  * Returns the composer manifest constraints ("require", "suggest" or "conflict") from the given package meta data
  *
  * @param string $constraintType one of the MetaDataInterface::CONSTRAINT_TYPE_* constants
  * @param MetaData $packageMetaData
  * @return array in the format array('<ComposerPackageName>' => '*', ...)
  * @deprecated This will be removed with Flow 4.0 together with the MetaData model
  */
 protected function getComposerManifestConstraints($constraintType, MetaData $packageMetaData)
 {
     $composerManifestConstraints = [];
     $constraints = $packageMetaData->getConstraintsByType($constraintType);
     foreach ($constraints as $constraint) {
         if (!$constraint instanceof MetaData\PackageConstraint) {
             continue;
         }
         $composerName = isset($this->packageStatesConfiguration['packages'][$constraint->getValue()]['composerName']) ? $this->packageStatesConfiguration['packages'][$constraint->getValue()]['composerName'] : ComposerUtility::getComposerPackageNameFromPackageKey($constraint->getValue());
         $composerManifestConstraints[$composerName] = '*';
     }
     return $composerManifestConstraints;
 }
 /**
  * Generates composer manifest data out of a MetaData object.
  *
  * @param string $packageType
  * @param MetaData|null $packageMetaData
  * @return array manifest data generated from the MetaData object
  * @deprecated This method will be removed with Flow 4.0 together with the MetaData model
  */
 protected function generateManifestFromMetaDataAndType($packageType, \TYPO3\Flow\Package\MetaData $packageMetaData = null)
 {
     $manifest = ['type' => $packageType, 'description' => 'Add description here', 'require' => ['typo3/flow' => '*']];
     if ($packageMetaData === null) {
         return $manifest;
     }
     if ($packageMetaData->getPackageType() !== null) {
         $manifest['type'] = $packageMetaData->getPackageType();
     }
     $manifest['description'] = $packageMetaData->getDescription() ?: $manifest['description'];
     if ($packageMetaData->getVersion()) {
         $manifest['version'] = $packageMetaData->getVersion();
     }
     $dependsConstraints = $this->getComposerManifestConstraints(MetaDataInterface::CONSTRAINT_TYPE_DEPENDS, $packageMetaData);
     if ($dependsConstraints !== []) {
         $manifest['require'] = $dependsConstraints;
     }
     $suggestsConstraints = $this->getComposerManifestConstraints(MetaDataInterface::CONSTRAINT_TYPE_SUGGESTS, $packageMetaData);
     if ($suggestsConstraints !== []) {
         $manifest['suggest'] = $suggestsConstraints;
     }
     $conflictsConstraints = $this->getComposerManifestConstraints(MetaDataInterface::CONSTRAINT_TYPE_CONFLICTS, $packageMetaData);
     if ($conflictsConstraints !== []) {
         $manifest['conflict'] = $conflictsConstraints;
     }
     return $manifest;
 }
 /**
  * Write a composer manifest for the package.
  *
  * @param string $manifestPath
  * @param string $packageKey
  * @param MetaData $packageMetaData
  * @return void
  */
 protected function writeComposerManifest($manifestPath, $packageKey, \TYPO3\Flow\Package\MetaData $packageMetaData = null)
 {
     $manifest = array('name' => $this->getComposerPackageNameFromPackageKey($packageKey));
     if ($packageMetaData !== null) {
         $manifest['type'] = $packageMetaData->getPackageType();
         $manifest['description'] = $packageMetaData->getDescription() ?: 'Add description here';
         if ($packageMetaData->getVersion()) {
             $manifest['version'] = $packageMetaData->getVersion();
         }
         $dependsConstraints = $this->getComposerManifestConstraints(MetaDataInterface::CONSTRAINT_TYPE_DEPENDS, $packageMetaData);
         if ($dependsConstraints !== array()) {
             $manifest['require'] = $dependsConstraints;
         }
         $suggestsConstraints = $this->getComposerManifestConstraints(MetaDataInterface::CONSTRAINT_TYPE_SUGGESTS, $packageMetaData);
         if ($suggestsConstraints !== array()) {
             $manifest['suggest'] = $suggestsConstraints;
         }
         $conflictsConstraints = $this->getComposerManifestConstraints(MetaDataInterface::CONSTRAINT_TYPE_CONFLICTS, $packageMetaData);
         if ($conflictsConstraints !== array()) {
             $manifest['conflict'] = $conflictsConstraints;
         }
     } else {
         $manifest['type'] = 'typo3-flow-package';
         $manifest['description'] = '';
     }
     if (!isset($manifest['require']) || empty($manifest['require'])) {
         $manifest['require'] = array('typo3/flow' => '*');
     }
     $manifest['autoload'] = array('psr-0' => array(str_replace('.', '\\', $packageKey) => 'Classes'));
     if (defined('JSON_PRETTY_PRINT')) {
         file_put_contents(Files::concatenatePaths(array($manifestPath, 'composer.json')), json_encode($manifest, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     } else {
         file_put_contents(Files::concatenatePaths(array($manifestPath, 'composer.json')), json_encode($manifest));
     }
 }
示例#8
0
 /**
  * Write a composer manifest for the package.
  *
  * @param string $manifestPath
  * @param string $packageKey
  * @param MetaData $packageMetaData
  * @return void
  */
 protected function writeComposerManifest($manifestPath, $packageKey, \TYPO3\Flow\Package\MetaData $packageMetaData = NULL)
 {
     $manifest = array();
     $nameParts = explode('.', $packageKey);
     $vendor = array_shift($nameParts);
     $manifest['name'] = strtolower($vendor . '/' . implode('-', $nameParts));
     if ($packageMetaData !== NULL) {
         $manifest['type'] = $packageMetaData->getPackageType();
         $manifest['description'] = $packageMetaData->getDescription();
         $manifest['version'] = $packageMetaData->getVersion();
     } else {
         $manifest['type'] = 'typo3-flow-package';
         $manifest['description'] = '';
     }
     $manifest['require'] = array('typo3/flow' => '*');
     $manifest['autoload'] = array('psr-0' => array(str_replace('.', '\\', $packageKey) => 'Classes'));
     if (defined('JSON_PRETTY_PRINT')) {
         file_put_contents(Files::concatenatePaths(array($manifestPath, 'composer.json')), json_encode($manifest, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     } else {
         file_put_contents(Files::concatenatePaths(array($manifestPath, 'composer.json')), json_encode($manifest));
     }
 }
示例#9
0
 /**
  * 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 \TYPO3\Flow\Package\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 ($this->packages as $upperCamelCasedPackageKey => $_) {
         $this->packageKeys[strtolower($upperCamelCasedPackageKey)] = $upperCamelCasedPackageKey;
     }
     $this->activatePackage($packageKey);
     return $package;
 }
示例#10
0
 /**
  * Write a composer manifest for the package.
  *
  * @param string $manifestPath
  * @param string $packageKey
  * @param MetaData $packageMetaData
  * @return void
  */
 protected function writeComposerManifest($manifestPath, $packageKey, \TYPO3\Flow\Package\MetaData $packageMetaData = NULL)
 {
     $manifest = array();
     $nameParts = explode('.', $packageKey);
     $vendor = array_shift($nameParts);
     $manifest['name'] = strtolower($vendor . '/' . implode('-', $nameParts));
     if ($packageMetaData !== NULL) {
         $manifest['type'] = $packageMetaData->getPackageType();
         $manifest['description'] = $packageMetaData->getDescription() ?: 'Add description here';
         if ($packageMetaData->getVersion()) {
             $manifest['version'] = $packageMetaData->getVersion();
         }
         $manifest['require'] = array();
         $dependencies = $packageMetaData->getConstraintsByType(MetaDataInterface::CONSTRAINT_TYPE_DEPENDS);
         foreach ($dependencies as $dependencyConstraint) {
             if ($dependencyConstraint instanceof \TYPO3\Flow\Package\MetaData\PackageConstraint) {
                 if (isset($this->packageStatesConfiguration['packages'][$dependencyConstraint->getValue()]['composerName'])) {
                     $manifest['require'][$this->packageStatesConfiguration['packages'][$dependencyConstraint->getValue()]['composerName']] = '*';
                 }
             }
         }
     } else {
         $manifest['type'] = 'typo3-flow-package';
         $manifest['description'] = '';
     }
     if (!isset($manifest['require']) || empty($manifest['require'])) {
         $manifest['require'] = array('typo3/flow' => '*');
     }
     $manifest['autoload'] = array('psr-0' => array(str_replace('.', '\\', $packageKey) => 'Classes'));
     if (defined('JSON_PRETTY_PRINT')) {
         file_put_contents(Files::concatenatePaths(array($manifestPath, 'composer.json')), json_encode($manifest, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     } else {
         file_put_contents(Files::concatenatePaths(array($manifestPath, 'composer.json')), json_encode($manifest));
     }
 }