require dirname(__FILE__) . '/../../library/FabricationEngine.php'; require dirname(__FILE__) . '/../../library/Fabricator.php'; require dirname(__FILE__) . '/../../library/PhpClass.php'; require dirname(__FILE__) . '/../../library/UML.php'; require dirname(__FILE__) . '/../../library/Html.php'; try { if (PHP_SAPI !== 'cli') { throw new Exception('This is command line script'); } else { $engine = new \Fabrication\FabricationEngine(); $UML = new \Fabrication\UML($engine); // get diagram name from script argument or default. $diagramName = isset($argv[1]) ? $argv[1] : 'Application'; $diagramPath = dirname(__FILE__) . '/' . $diagramName . '.dia'; // load the diagram $engine->run($diagramPath, 'file', 'xml'); // show layer objects in a php class representation. foreach ($UML->retriveLayerObjects() as $name => $object) { $objectType = $object->attributes->getNamedItem('type')->nodeValue; // UML - Class if ($object->nodeName == 'dia:object' && $objectType == "UML - Class") { $phpClass = new \Fabrication\PhpClass(); $phpClass->setName($name); $phpClass->setStereotype($UML->getStereoType($object)); $umlAttributes = $UML->getAttributes($object); if (is_object($umlAttributes) && $umlAttributes->length > 0) { foreach ($umlAttributes as $umlAttribute) { $phpClass->setProperty(['name' => $UML->retriveAttributeName($umlAttribute), 'type' => $UML->retriveAttributeType($umlAttribute), 'visibility' => $UML->retriveAttributeVisibility($umlAttribute)]); } } $umlOperations = $UML->getOperations($object);
<?php require dirname(__FILE__) . '/../../library/FabricationEngine.php'; $engine = new \Fabrication\FabricationEngine(); $engine->run('http://slashdot.org', 'file'); echo $engine->saveHTML();
<?php require dirname(__FILE__) . '/../../library/FabricationEngine.php'; $engine = new \Fabrication\FabricationEngine(); echo $engine->getDoctype() . "\n"; $engine->setOption('doctype', 'html.5'); echo $engine->getDoctype() . "\n"; $template = '<html><head><title></title></head><body>' . '<h2>Hello 1</h2><article>Hello World 1</article>' . '<h2>Hello 2</h2><article>Hello World 2</article>' . '</body></html>'; $engine->run($template); $result = $engine->getArticle(); var_dump($result->item(0)->nodeValue); var_dump($result->item(1)->nodeValue); $engine->view('//article[position()=1]'); $engine->view('//article[position()=2]');
<?php require dirname(__FILE__) . '/../../library/FabricationEngine.php'; $engine = new \Fabrication\FabricationEngine(); $engine->registerNamespace('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $engine->registerNamespace('xmlns:slash', 'http://purl.org/rss/1.0/modules/slash/'); $engine->run('https://packagist.org/feeds/vendor.components.rss', 'file'); $channelTitle = $engine->query('//rss/channel/title'); $channelDescription = $engine->query('//rss/channel/description'); $channelGenerator = $engine->query('//rss/channel/generator'); $channelItems = $engine->query('//rss/channel/item'); $output = "{\n"; foreach ($channelItems as $item) { foreach ($item->childNodes as $key => $value) { if ($value->nodeName == "guid") { $parts = explode(" ", $value->nodeValue); $output .= "\t\"require\": {\n"; $output .= "\t\t\t\"{$parts[0]}\": \"{$parts[1]}\"\n"; $output .= "\t},\n"; } } } $output .= "}\n\n"; echo $output;