. */ namespace Doctrine\DBAL\Schema\Visitor; use Doctrine\DBAL\Platforms\AbstractPlatform, Doctrine\DBAL\Schema\Table, Doctrine\DBAL\Schema\Schema, Doctrine\DBAL\Schema\Column, Doctrine\DBAL\Schema\ForeignKeyConstraint, Doctrine\DBAL\Schema\Constraint, Doctrine\DBAL\Schema\Sequence, Doctrine\DBAL\Schema\Index; class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor { private $output = ''; public function acceptColumn(Table $table, Column $column) { } public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) { $this->output .= $this->createNodeRelation( $fkConstraint->getLocalTableName() . ":col" . current($fkConstraint->getLocalColumns()).":se", $fkConstraint->getForeignTableName() . ":col" . current($fkConstraint->getForeignColumns()).":se", array( 'dir' => 'back', 'arrowtail' => 'dot', 'arrowhead' => 'normal', ) ); } public function acceptIndex(Table $table, Index $index) { } public function acceptSchema(Schema $schema) { $this->output = 'digraph "' . sha1( mt_rand() ) . '" {' . "\n"; $this->output .= 'splines = true;' . "\n"; $this->output .= 'overlap = false;' . "\n"; $this->output .= 'outputorder=edgesfirst;'."\n"; $this->output .= 'mindist = 0.6;' . "\n"; $this->output .= 'sep = .2;' . "\n"; } public function acceptSequence(Sequence $sequence) { } public function acceptTable(Table $table) { $this->output .= $this->createNode( $table->getName(), array( 'label' => $this->createTableLabel( $table ), 'shape' => 'plaintext', ) ); } private function createTableLabel( Table $table ) { // Start the table $label = '<
' . $table->getName() . ' | ||
'; $label .= '' . $columnLabel . ''; $label .= ' | ' . strtolower($column->getType()) . ' | '; $label .= ''; if ($table->hasPrimaryKey() && in_array($column->getName(), $table->getPrimaryKey()->getColumns())) { $label .= "\xe2\x9c\xb7"; } $label .= ' |