/**
  * 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;
 }
Beispiel #3
0
 /**
  * (For now) evaluates the package configuration
  *
  * @param \F3\FLOW3\Package\PackageInterface $package The package
  * @param array $packageConfiguration The configuration to evaluate
  * @return void
  * @author Robert Lemke <*****@*****.**>
  * @see initializePackages()
  * @todo needs refactoring and be moved to elsewhere (package manager)
  */
 protected function evaluatePackageConfiguration(\F3\FLOW3\Package\PackageInterface $package, array $packageConfiguration)
 {
     if (isset($packageConfiguration['classLoader'])) {
         if (isset($packageConfiguration['classLoader']['specialClassNameAndPaths'])) {
             $classLoader = $this->objectManager->getObject('F3\\FLOW3\\Resource\\ClassLoader');
             foreach ($packageConfiguration['classLoader']['specialClassNameAndPaths'] as $className => $classFilePathAndName) {
                 $classFilePathAndName = str_replace('%PATH_PACKAGE%', $package->getPackagePath(), $classFilePathAndName);
                 $classFilePathAndName = str_replace('%PATH_PACKAGE_CLASSES%', $package->getClassesPath(), $classFilePathAndName);
                 $classFilePathAndName = str_replace('%PATH_PACKAGE_RESOURCES%', $package->getResourcesPath(), $classFilePathAndName);
                 $classLoader->setSpecialClassNameAndPath($className, $classFilePathAndName);
             }
         }
         if (isset($packageConfiguration['classLoader']['includePaths'])) {
             foreach ($packageConfiguration['classLoader']['includePaths'] as $includePath) {
                 $includePath = str_replace('%PATH_PACKAGE%', $package->getPackagePath(), $includePath);
                 $includePath = str_replace('%PATH_PACKAGE_CLASSES%', $package->getClassesPath(), $includePath);
                 $includePath = str_replace('%PATH_PACKAGE_RESOURCES%', $package->getResourcesPath(), $includePath);
                 $includePath = str_replace('/', DIRECTORY_SEPARATOR, $includePath);
                 set_include_path($includePath . PATH_SEPARATOR . get_include_path());
             }
         }
     }
 }