/** * Write metadata for the given package into a Package.xml file. * * @param \F3\FLOW3\Package\PackageInterface $package The package - also contains information about where to write the Package meta file * @param \F3\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 * @author Christopher Hlubek <*****@*****.**> * @author Robert Lemke <*****@*****.**> */ public function writePackageMetaData(\F3\FLOW3\Package\PackageInterface $package, \F3\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) { $this->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) { $this->writeConstraint($xml, $constraint); } $xml->endElement(); } } $xml->endElement(); } $xml->endElement(); return TRUE; }
/** * Read the package metadata for the given package from the * Package.xml file contained in the package * * @param \F3\FLOW3\Package\PackageInterface $package The package to read metadata for * @return MetaData A package meta data instance with the data from the package's Package.xml file. * @author Christopher Hlubek <*****@*****.**> */ public function readPackageMetaData(\F3\FLOW3\Package\PackageInterface $package) { $packageInfoPath = $package->getMetaPath(); $meta = new \F3\FLOW3\Package\MetaData($package->getPackageKey()); $xml = simplexml_load_file(\F3\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); $this->readCategories($xml, $meta); $this->readParties($xml, $meta); $this->readConstraints($xml, $meta); } return $meta; }