. */ include_once 'propel/engine/database/model/AppData.php'; //require_once 'phing/Task.php'; /** * A task to generate Graphviz png images from propel datamodel. * * @author Mark Kimsal * @version $Revision: 536 $ * @package propel.phing */ class PropelGraphvizTask extends AbstractPropelDataModelTask { /** * The properties file that maps an SQL file to a particular database. * @var PhingFile */ private $sqldbmap; /** * Name of the database. */ private $database; /** * Name of the output directory. */ private $outDir; /** * Set the sqldbmap. * @param PhingFile $sqldbmap The db map. */ public function setOutputDirectory(PhingFile $out) { if (!$out->exists()) { $out->mkdirs(); } $this->outDir = $out; } /** * Set the sqldbmap. * @param PhingFile $sqldbmap The db map. */ public function setSqlDbMap(PhingFile $sqldbmap) { $this->sqldbmap = $sqldbmap; } /** * Get the sqldbmap. * @return PhingFile $sqldbmap. */ public function getSqlDbMap() { return $this->sqldbmap; } /** * Set the database name. * @param string $database */ public function setDatabase($database) { $this->database = $database; } /** * Get the database name. * @return string */ public function getDatabase() { return $this->database; } public function main() { $count = 0; $dotSyntax = ''; // file we are going to create $dbMaps = $this->getDataModelDbMap(); foreach ($this->getDataModels() as $dataModel) { $dotSyntax .= "digraph G {\n"; foreach ($dataModel->getDatabases() as $database) { $this->log("db: " . $database->getName()); //print the tables foreach($database->getTables() as $tbl) { $this->log("\t+ " . $tbl->getName()); ++$count; $dotSyntax .= 'node'.$tbl->getName().' [label="{