Beispiel #1
0
 /**
  * Write metadata for the given package into a Package.xml file.
  *
  * @param \TYPO3\FLOW3\Package\PackageInterface $package The package - also contains information about where to write the Package meta file
  * @param \TYPO3\FLOW3\Package\MetaDataInterface $meta The MetaData object containing the information to write
  * @return boolean If writing the XML file was successful returns TRUE, otherwise FALSE
  */
 public static function writePackageMetaData(\TYPO3\FLOW3\Package\PackageInterface $package, \TYPO3\FLOW3\Package\MetaDataInterface $meta)
 {
     $xml = new \XMLWriter();
     if ($xml->openURI($package->getMetaPath() . 'Package.xml') === FALSE) {
         return FALSE;
     }
     $xml->setIndent(true);
     $xml->setIndentString(chr(9));
     $xml->startDocument('1.0', 'utf-8', 'yes');
     $xml->startElement('package');
     $xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->writeAttribute('xmlns', 'http://typo3.org/ns/2008/flow3/package');
     $xml->writeAttribute('version', '1.0');
     $xml->writeElement('key', $meta->getPackageKey());
     $xml->writeElement('title', $meta->getTitle());
     $xml->writeElement('description', $meta->getDescription());
     $xml->writeElement('version', $meta->getVersion());
     if (count($meta->getCategories())) {
         $xml->startElement('categories');
         foreach ($meta->getCategories() as $category) {
             $xml->writeElement('category', $category);
         }
         $xml->endElement();
     }
     if (count($meta->getParties())) {
         $xml->startElement('parties');
         foreach ($meta->getParties() as $party) {
             self::writeParty($xml, $party);
         }
         $xml->endElement();
     }
     if (count($meta->getConstraints())) {
         $xml->startElement('constraints');
         foreach ($meta->getConstraintTypes() as $constraintType) {
             $constraints = $meta->getConstraintsByType($constraintType);
             if (count($constraints)) {
                 $xml->startElement($constraintType);
                 foreach ($constraints as $constraint) {
                     self::writeConstraint($xml, $constraint);
                 }
                 $xml->endElement();
             }
         }
         $xml->endElement();
     }
     $xml->endElement();
     return TRUE;
 }
Beispiel #2
0
 /**
  * Read the package metadata for the given package from the
  * Package.xml file contained in the package
  *
  * @param \TYPO3\FLOW3\Package\PackageInterface $package The package to read metadata for
  * @return \TYPO3\FLOW3\Package\MetaData A package meta data instance with the data from the package's Package.xml file.
  */
 public static function readPackageMetaData(\TYPO3\FLOW3\Package\PackageInterface $package)
 {
     $packageInfoPath = $package->getMetaPath();
     $meta = new \TYPO3\FLOW3\Package\MetaData($package->getPackageKey());
     $xml = simplexml_load_file(\TYPO3\FLOW3\Utility\Files::concatenatePaths(array($packageInfoPath, 'Package.xml')));
     if ($xml === FALSE) {
         $meta->setDescription('[Package.xml could not be read.]');
     } else {
         $meta->setVersion((string) $xml->version);
         $meta->setTitle((string) $xml->title);
         $meta->setDescription((string) $xml->description);
         self::readCategories($xml, $meta);
         self::readParties($xml, $meta);
         self::readConstraints($xml, $meta);
     }
     return $meta;
 }