Beispiel #1
0
 /**
  * Update an instance of Xmi_Exporter with the current output settings
  * 
  * @param PHP_UML_Output_Xmi_Exporter $e Exporter object to update
  */
 private function setOutputXmiOptions(PHP_UML_Output_Xmi_Exporter $e)
 {
     $e->setLogicalView($this->logicalView);
     $e->setComponentView($this->componentView);
     $e->setDeploymentView($this->deploymentView);
     $e->setStereotypes($this->docblocks);
 }
Beispiel #2
0
 /**
  * Rebuilds the set of original objects (stored in data-providers).
  * You should not need to run it. If you do so, run it with a
  * trusted version of UML.
  */
 public static function rebuildExpectedParsePhp()
 {
     foreach (new DirectoryIterator(self::SUITE_DIR) as $file) {
         if (!$file->isDot() && !$file->isDir()) {
             $filename = $file->getFilename();
             if (substr($filename, -4) == '.php') {
                 $uml = self::getPhpUmlObject();
                 $uml->parseFile(self::SUITE_DIR . $filename);
                 $str = serialize($uml->getModel());
                 $ptr = fopen(self::SUITE_DIR . self::PROVIDERS_DIR . $filename . '.obj', 'wb');
                 fwrite($ptr, $str);
                 fclose($ptr);
             }
         }
     }
     // Global check (the two XMI files)
     $uml = self::getPhpUmlObject();
     $uml->parseDirectory(self::SUITE_DIR);
     $e = new PHP_UML_Output_Xmi_Exporter();
     $e->setDeploymentView(true);
     $e->setComponentView(false);
     $e->setStereotypes(true);
     $e->setXmiVersion(1);
     $e->export(self::SUITE_DIR . self::PROVIDERS_DIR . 'global1.xmi');
     $e->setXmiVersion(2);
     $e->export(self::SUITE_DIR . self::PROVIDERS_DIR . 'global2.xmi');
     // used by UmlParserTest::providerModelGlobal():
     $str = serialize($uml->getModel());
     $ptr = fopen(self::SUITE_DIR . self::PROVIDERS_DIR . 'global.obj', 'wb');
     fwrite($ptr, $str);
     fclose($ptr);
 }
Beispiel #3
0
 /**
  * Generates output data by applying a transformation on the XMI stored in the
  * property $xmi
  *
  * @param string $outputDir Output folder
  * 
  * @return DOMDocument A DOM document containing the result of the XSLT
  */
 public function export($outputDir)
 {
     $xslFile = $this->getXslFilepath();
     if (empty($this->xmiDocument)) {
         $temp = new PHP_UML_Output_Xmi_Exporter();
         /*
          * Component views and deployment views don't mean anything
          * for output formats other than XMI. Yet, since ExporterXSL is
          * a subclass of ExportXMI, we must force these options to
          * false, otherwise they will appear in the output produced by 
          * the XSL transformation:
          */
         $temp->setComponentView(false);
         $temp->setDeploymentView(false);
         $temp->setModel($this->structure);
         $temp->generateXmi();
         $this->xmiDocument = $temp->getXmiDocument();
     }
     if (file_exists($xslFile)) {
         return $this->exportFromXml($outputDir, $xslFile, $this->xmiDocument->dump());
     } else {
         throw new PHP_UML_Exception('Could not find the XSL template file. It must be named ' . self::STARTING_TPL . ', under Format/YourTemplate/');
     }
 }
Beispiel #4
0
 */
$t = new PHP_UML();
$t->dollar = false;
// We don't keep the $ before the variable names
$t->componentView = false;
// We don't want a component view to be included
$t->deploymentView = false;
// We don't want a deployment view (artifacts+folders)
$t->docblocks = true;
// We want the parser to look into the class/file comments
$t->setInput('test1.php.txt, test2.php.txt');
// We want only "test1.php.txt" and "test2.php.txt"
$t->parse('testModel');
// The files are parsed, and a UML model named "testModel" is built
// we retrieve an XMI implementation of an Exporter object, and set the model:
$e = new PHP_UML_Output_Xmi_Exporter();
$e->setModel($t->getModel());
// we set the XMI version (2.1 being the default if not set)
$e->setXmiVersion(1);
// we set the encoding (iso-8859-1 being the default if not set):
$e->setEncoding('UTF-8');
// and we export XMI to a file:
$e->export('test_example2.xmi');
// we can also print the serialized XMI by retrieving an XmiDocument from the exporter object:
echo htmlentities($e->getXmiDocument()->dump());
/**
 * Example 3 : Example with a whole directory of PHP files to parse. We just want to
 * generate the API documentation in HTML.
 */
$t = new PHP_UML();
$t->setMatchPatterns(array('*.php', '*.txt'));
Beispiel #5
0
<?php

require_once 'PHP/UML.php';
$importer = new PHP_UML_Input_PHP_FileScanner();
$importer->setDirectories(array('./app/models', './app/controllers', './app/repositories', './app/repositories/interfaces'));
$importer->import();
$exporter = new PHP_UML_Output_Xmi_Exporter();
$exporter->setModel($importer->getModel());
$exporter->setXmiVersion(1);
$exporter->setEncoding('utf-8');
$exporter->setDeploymentView(true);
$exporter->setComponentView(true);
$exporter->export('./uml');