Commit a5799c4d authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge branch 'DBAL-107'

parents 8ed71eb5 d3436539
...@@ -41,8 +41,8 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ...@@ -41,8 +41,8 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
{ {
$this->output .= $this->createNodeRelation( $this->output .= $this->createNodeRelation(
$fkConstraint->getLocalTableName(), $fkConstraint->getLocalTableName() . ":col" . current($fkConstraint->getLocalColumns()).":se",
$fkConstraint->getForeignTableName(), $fkConstraint->getForeignTableName() . ":col" . current($fkConstraint->getForeignColumns()).":se",
array( array(
'dir' => 'back', 'dir' => 'back',
'arrowtail' => 'dot', 'arrowtail' => 'dot',
...@@ -61,6 +61,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ...@@ -61,6 +61,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
$this->output = 'digraph "' . sha1( mt_rand() ) . '" {' . "\n"; $this->output = 'digraph "' . sha1( mt_rand() ) . '" {' . "\n";
$this->output .= 'splines = true;' . "\n"; $this->output .= 'splines = true;' . "\n";
$this->output .= 'overlap = false;' . "\n"; $this->output .= 'overlap = false;' . "\n";
$this->output .= 'outputorder=edgesfirst;'."\n";
$this->output .= 'mindist = 0.6;' . "\n"; $this->output .= 'mindist = 0.6;' . "\n";
$this->output .= 'sep = .2;' . "\n"; $this->output .= 'sep = .2;' . "\n";
} }
...@@ -72,43 +73,37 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ...@@ -72,43 +73,37 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public function acceptTable(Table $table) public function acceptTable(Table $table)
{ {
$name = $table->getName();
$columns = array();
foreach ($table->getColumns() AS $column) {
$name = $column->getName();
if (in_array($name, $table->getPrimaryKey()->getColumns())) {
$name = $name . " \xe2\x9c\xb6";
}
$columns[] = $name;
}
$this->output .= $this->createNode( $this->output .= $this->createNode(
$table->getName(), $table->getName(),
array( array(
'label' => $this->createTableLabel( $table->getName(), $columns ), 'label' => $this->createTableLabel( $table ),
'shape' => 'plaintext', 'shape' => 'plaintext',
) )
); );
} }
private function createTableLabel( $name, $columns ) private function createTableLabel( Table $table )
{ {
// Start the table // Start the table
$label = '<<TABLE CELLSPACING="0" BORDER="0" ALIGN="LEFT">'; $label = '<<TABLE CELLSPACING="0" BORDER="1" ALIGN="LEFT">';
// The title // The title
$label .= '<TR><TD BORDER="1" ALIGN="CENTER" BGCOLOR="#fcaf3e"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="12">' . $name . '</FONT></TD></TR>'; $label .= '<TR><TD BORDER="1" COLSPAN="3" ALIGN="CENTER" BGCOLOR="#fcaf3e"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="12">' . $table->getName() . '</FONT></TD></TR>';
// The attributes block // The attributes block
$label .= '<TR><TD BORDER="1" ALIGN="LEFT" BGCOLOR="#eeeeec">'; foreach( $table->getColumns() as $column ) {
if ( count( $columns ) === 0 ) { $columnLabel = $column->getName();
$label .= ' ';
} $label .= '<TR>';
foreach( $columns as $attribute ) { $label .= '<TD BORDER="0" ALIGN="LEFT" BGCOLOR="#eeeeec">';
$label .= '<FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="10">' . $attribute . '</FONT><BR ALIGN="LEFT"/>'; $label .= '<FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="12">' . $columnLabel . '</FONT>';
$label .= '</TD><TD BORDER="0" ALIGN="LEFT" BGCOLOR="#eeeeec"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="10">' . strtolower($column->getType()) . '</FONT></TD>';
$label .= '<TD BORDER="0" ALIGN="RIGHT" BGCOLOR="#eeeeec" PORT="col'.$column->getName().'">';
if (in_array($column->getName(), $table->getPrimaryKey()->getColumns())) {
$label .= "\xe2\x9c\xb7";
}
$label .= '</TD></TR>';
} }
$label .= '</TD></TR>';
// End the table // End the table
$label .= '</TABLE>>'; $label .= '</TABLE>>';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment