Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
5eea9913
Commit
5eea9913
authored
Feb 10, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started refactoring Schema and SchemaDiff Visitors.
parent
65806f59
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
235 additions
and
140 deletions
+235
-140
SchemaDiff.php
lib/Doctrine/DBAL/Schema/SchemaDiff.php
+0
-2
AbstractVisitor.php
lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php
+80
-0
CreateSchemaSqlCollector.php
...Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
+34
-55
DbDeployExporter.php
lib/Doctrine/DBAL/Schema/Visitor/DbDeployExporter.php
+18
-0
DropSchemaSqlCollector.php
lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php
+2
-30
Graphviz.php
lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php
+23
-26
RemoveNamespacedAssets.php
lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
+2
-19
SchemaDiffVisitor.php
lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php
+68
-0
Visitor.php
lib/Doctrine/DBAL/Schema/Visitor/Visitor.php
+8
-8
No files found.
lib/Doctrine/DBAL/Schema/SchemaDiff.php
View file @
5eea9913
...
@@ -24,12 +24,10 @@ use \Doctrine\DBAL\Platforms\AbstractPlatform;
...
@@ -24,12 +24,10 @@ use \Doctrine\DBAL\Platforms\AbstractPlatform;
/**
/**
* Schema Diff
* Schema Diff
*
*
*
* @link www.doctrine-project.org
* @link www.doctrine-project.org
* @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
* @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
* @license http://ez.no/licenses/new_bsd New BSD License
* @since 2.0
* @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
*/
class
SchemaDiff
class
SchemaDiff
...
...
lib/Doctrine/DBAL/Schema/Visitor/AbstractVisitor.php
0 → 100644
View file @
5eea9913
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Schema\Visitor
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\DBAL\Schema\Column
;
use
Doctrine\DBAL\Schema\ForeignKeyConstraint
;
use
Doctrine\DBAL\Schema\Constraint
;
use
Doctrine\DBAL\Schema\Sequence
;
use
Doctrine\DBAL\Schema\Index
;
/**
* Abstract Visitor with empty methods for easy extension.
*/
class
AbstractVisitor
implements
Visitor
{
/**
* @param Schema $schema
*/
public
function
acceptSchema
(
Schema
$schema
)
{
}
/**
* @param Table $table
*/
public
function
acceptTable
(
Table
$table
)
{
}
/**
* @param Column $column
*/
public
function
acceptColumn
(
Table
$table
,
Column
$column
)
{
}
/**
* @param Table $localTable
* @param ForeignKeyConstraint $fkConstraint
*/
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
{
}
/**
* @param Table $table
* @param Index $index
*/
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
{
}
/**
* @param Sequence $sequence
*/
public
function
acceptSequence
(
Sequence
$sequence
)
{
}
}
lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
View file @
5eea9913
<?php
<?php
/*
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
@@ -24,49 +22,39 @@ namespace Doctrine\DBAL\Schema\Visitor;
...
@@ -24,49 +22,39 @@ namespace Doctrine\DBAL\Schema\Visitor;
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Column
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Sequence
,
Doctrine\DBAL\Schema\Sequence
;
Doctrine\DBAL\Schema\Index
;
class
CreateSchemaSqlCollector
implements
Visitor
class
CreateSchemaSqlCollector
extends
Abstract
Visitor
{
{
/**
/**
* @var array
* @var array
*/
*/
private
$
_
createTableQueries
=
array
();
private
$createTableQueries
=
array
();
/**
/**
* @var array
* @var array
*/
*/
private
$
_
createSequenceQueries
=
array
();
private
$createSequenceQueries
=
array
();
/**
/**
* @var array
* @var array
*/
*/
private
$
_
createFkConstraintQueries
=
array
();
private
$createFkConstraintQueries
=
array
();
/**
/**
*
*
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
*/
private
$
_
platform
=
null
;
private
$platform
=
null
;
/**
/**
* @param AbstractPlatform $platform
* @param AbstractPlatform $platform
*/
*/
public
function
__construct
(
AbstractPlatform
$platform
)
public
function
__construct
(
AbstractPlatform
$platform
)
{
{
$this
->
_platform
=
$platform
;
$this
->
platform
=
$platform
;
}
/**
* @param Schema $schema
*/
public
function
acceptSchema
(
Schema
$schema
)
{
}
}
/**
/**
...
@@ -78,17 +66,12 @@ class CreateSchemaSqlCollector implements Visitor
...
@@ -78,17 +66,12 @@ class CreateSchemaSqlCollector implements Visitor
{
{
$namespace
=
$this
->
getNamespace
(
$table
);
$namespace
=
$this
->
getNamespace
(
$table
);
$this
->
_
createTableQueries
[
$namespace
]
=
array_merge
(
$this
->
createTableQueries
[
$namespace
]
=
array_merge
(
$this
->
_
createTableQueries
[
$namespace
],
$this
->
createTableQueries
[
$namespace
],
$this
->
_
platform
->
getCreateTableSQL
(
$table
)
$this
->
platform
->
getCreateTableSQL
(
$table
)
);
);
}
}
public
function
acceptColumn
(
Table
$table
,
Column
$column
)
{
}
/**
/**
* @param Table $localTable
* @param Table $localTable
* @param ForeignKeyConstraint $fkConstraint
* @param ForeignKeyConstraint $fkConstraint
...
@@ -97,25 +80,16 @@ class CreateSchemaSqlCollector implements Visitor
...
@@ -97,25 +80,16 @@ class CreateSchemaSqlCollector implements Visitor
{
{
$namespace
=
$this
->
getNamespace
(
$localTable
);
$namespace
=
$this
->
getNamespace
(
$localTable
);
if
(
$this
->
_
platform
->
supportsForeignKeyConstraints
())
{
if
(
$this
->
platform
->
supportsForeignKeyConstraints
())
{
$this
->
_
createFkConstraintQueries
[
$namespace
]
=
array_merge
(
$this
->
createFkConstraintQueries
[
$namespace
]
=
array_merge
(
$this
->
_
createFkConstraintQueries
[
$namespace
],
$this
->
createFkConstraintQueries
[
$namespace
],
(
array
)
$this
->
_
platform
->
getCreateForeignKeySQL
(
(
array
)
$this
->
platform
->
getCreateForeignKeySQL
(
$fkConstraint
,
$localTable
$fkConstraint
,
$localTable
)
)
);
);
}
}
}
}
/**
* @param Table $table
* @param Index $index
*/
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
{
}
/**
/**
* @param Sequence $sequence
* @param Sequence $sequence
*/
*/
...
@@ -123,19 +97,19 @@ class CreateSchemaSqlCollector implements Visitor
...
@@ -123,19 +97,19 @@ class CreateSchemaSqlCollector implements Visitor
{
{
$namespace
=
$this
->
getNamespace
(
$sequence
);
$namespace
=
$this
->
getNamespace
(
$sequence
);
$this
->
_
createSequenceQueries
[
$namespace
]
=
array_merge
(
$this
->
createSequenceQueries
[
$namespace
]
=
array_merge
(
$this
->
_
createSequenceQueries
[
$namespace
],
$this
->
createSequenceQueries
[
$namespace
],
(
array
)
$this
->
_
platform
->
getCreateSequenceSQL
(
$sequence
)
(
array
)
$this
->
platform
->
getCreateSequenceSQL
(
$sequence
)
);
);
}
}
private
function
getNamespace
(
$asset
)
private
function
getNamespace
(
$asset
)
{
{
$namespace
=
$asset
->
getNamespaceName
()
?:
'default'
;
$namespace
=
$asset
->
getNamespaceName
()
?:
'default'
;
if
(
!
isset
(
$this
->
_
createTableQueries
[
$namespace
]))
{
if
(
!
isset
(
$this
->
createTableQueries
[
$namespace
]))
{
$this
->
_
createTableQueries
[
$namespace
]
=
array
();
$this
->
createTableQueries
[
$namespace
]
=
array
();
$this
->
_
createSequenceQueries
[
$namespace
]
=
array
();
$this
->
createSequenceQueries
[
$namespace
]
=
array
();
$this
->
_
createFkConstraintQueries
[
$namespace
]
=
array
();
$this
->
createFkConstraintQueries
[
$namespace
]
=
array
();
}
}
return
$namespace
;
return
$namespace
;
...
@@ -146,9 +120,9 @@ class CreateSchemaSqlCollector implements Visitor
...
@@ -146,9 +120,9 @@ class CreateSchemaSqlCollector implements Visitor
*/
*/
public
function
resetQueries
()
public
function
resetQueries
()
{
{
$this
->
_
createTableQueries
=
array
();
$this
->
createTableQueries
=
array
();
$this
->
_
createSequenceQueries
=
array
();
$this
->
createSequenceQueries
=
array
();
$this
->
_
createFkConstraintQueries
=
array
();
$this
->
createFkConstraintQueries
=
array
();
}
}
/**
/**
...
@@ -159,20 +133,25 @@ class CreateSchemaSqlCollector implements Visitor
...
@@ -159,20 +133,25 @@ class CreateSchemaSqlCollector implements Visitor
public
function
getQueries
()
public
function
getQueries
()
{
{
$sql
=
array
();
$sql
=
array
();
foreach
(
array_keys
(
$this
->
_createTableQueries
)
as
$namespace
)
{
if
(
$this
->
_platform
->
supportsSchemas
())
{
foreach
(
array_keys
(
$this
->
createTableQueries
)
as
$namespace
)
{
if
(
$this
->
platform
->
supportsSchemas
())
{
// TODO: Create Schema here
// TODO: Create Schema here
}
}
}
}
foreach
(
$this
->
_createTableQueries
as
$schemaSql
)
{
foreach
(
$this
->
createTableQueries
as
$schemaSql
)
{
$sql
=
array_merge
(
$sql
,
$schemaSql
);
$sql
=
array_merge
(
$sql
,
$schemaSql
);
}
}
foreach
(
$this
->
_createSequenceQueries
as
$schemaSql
)
{
foreach
(
$this
->
createSequenceQueries
as
$schemaSql
)
{
$sql
=
array_merge
(
$sql
,
$schemaSql
);
$sql
=
array_merge
(
$sql
,
$schemaSql
);
}
}
foreach
(
$this
->
_createFkConstraintQueries
as
$schemaSql
)
{
foreach
(
$this
->
createFkConstraintQueries
as
$schemaSql
)
{
$sql
=
array_merge
(
$sql
,
$schemaSql
);
$sql
=
array_merge
(
$sql
,
$schemaSql
);
}
}
return
$sql
;
return
$sql
;
}
}
}
}
lib/Doctrine/DBAL/Schema/Visitor/DbDeployExporter.php
0 → 100644
View file @
5eea9913
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php
View file @
5eea9913
<?php
<?php
/*
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
@@ -24,7 +22,6 @@ namespace Doctrine\DBAL\Schema\Visitor;
...
@@ -24,7 +22,6 @@ namespace Doctrine\DBAL\Schema\Visitor;
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Column
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Sequence
,
Doctrine\DBAL\Schema\Sequence
,
...
@@ -34,12 +31,11 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
...
@@ -34,12 +31,11 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
/**
/**
* Gather SQL statements that allow to completely drop the current schema.
* Gather SQL statements that allow to completely drop the current schema.
*
*
*
* @link www.doctrine-project.org
* @link www.doctrine-project.org
* @since 2.0
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
*/
class
DropSchemaSqlCollector
implements
Visitor
class
DropSchemaSqlCollector
extends
Abstract
Visitor
{
{
/**
/**
* @var \SplObjectStorage
* @var \SplObjectStorage
...
@@ -71,14 +67,6 @@ class DropSchemaSqlCollector implements Visitor
...
@@ -71,14 +67,6 @@ class DropSchemaSqlCollector implements Visitor
$this
->
clearQueries
();
$this
->
clearQueries
();
}
}
/**
* @param Schema $schema
*/
public
function
acceptSchema
(
Schema
$schema
)
{
}
/**
/**
* @param Table $table
* @param Table $table
*/
*/
...
@@ -87,14 +75,6 @@ class DropSchemaSqlCollector implements Visitor
...
@@ -87,14 +75,6 @@ class DropSchemaSqlCollector implements Visitor
$this
->
tables
->
attach
(
$table
);
$this
->
tables
->
attach
(
$table
);
}
}
/**
* @param Column $column
*/
public
function
acceptColumn
(
Table
$table
,
Column
$column
)
{
}
/**
/**
* @param Table $localTable
* @param Table $localTable
* @param ForeignKeyConstraint $fkConstraint
* @param ForeignKeyConstraint $fkConstraint
...
@@ -109,15 +89,6 @@ class DropSchemaSqlCollector implements Visitor
...
@@ -109,15 +89,6 @@ class DropSchemaSqlCollector implements Visitor
$this
->
constraints
[
$fkConstraint
]
=
$localTable
;
$this
->
constraints
[
$fkConstraint
]
=
$localTable
;
}
}
/**
* @param Table $table
* @param Index $index
*/
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
{
}
/**
/**
* @param Sequence $sequence
* @param Sequence $sequence
*/
*/
...
@@ -142,6 +113,7 @@ class DropSchemaSqlCollector implements Visitor
...
@@ -142,6 +113,7 @@ class DropSchemaSqlCollector implements Visitor
public
function
getQueries
()
public
function
getQueries
()
{
{
$sql
=
array
();
$sql
=
array
();
foreach
(
$this
->
constraints
as
$fkConstraint
)
{
foreach
(
$this
->
constraints
as
$fkConstraint
)
{
$localTable
=
$this
->
constraints
[
$fkConstraint
];
$localTable
=
$this
->
constraints
[
$fkConstraint
];
$sql
[]
=
$this
->
platform
->
getDropForeignKeySQL
(
$fkConstraint
,
$localTable
);
$sql
[]
=
$this
->
platform
->
getDropForeignKeySQL
(
$fkConstraint
,
$localTable
);
...
...
lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php
View file @
5eea9913
<?php
<?php
/*
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
...
@@ -23,21 +22,19 @@ namespace Doctrine\DBAL\Schema\Visitor;
...
@@ -23,21 +22,19 @@ namespace Doctrine\DBAL\Schema\Visitor;
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Column
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Constraint
;
Doctrine\DBAL\Schema\Sequence
,
Doctrine\DBAL\Schema\Index
;
class
Graphviz
implements
\Doctrine\DBAL\Schema\Visitor\Visitor
/**
* Create a Graphviz output of a Schema.
*/
class
Graphviz
extends
AbstractVisitor
{
{
/**
* @var string
*/
private
$output
=
''
;
private
$output
=
''
;
public
function
acceptColumn
(
Table
$table
,
Column
$column
)
{
}
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
{
{
$this
->
output
.=
$this
->
createNodeRelation
(
$this
->
output
.=
$this
->
createNodeRelation
(
...
@@ -51,11 +48,6 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -51,11 +48,6 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
);
);
}
}
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
{
}
public
function
acceptSchema
(
Schema
$schema
)
public
function
acceptSchema
(
Schema
$schema
)
{
{
$this
->
output
=
'digraph "'
.
sha1
(
mt_rand
()
)
.
'" {'
.
"
\n
"
;
$this
->
output
=
'digraph "'
.
sha1
(
mt_rand
()
)
.
'" {'
.
"
\n
"
;
...
@@ -66,11 +58,6 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -66,11 +58,6 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
$this
->
output
.=
'sep = .2;'
.
"
\n
"
;
$this
->
output
.=
'sep = .2;'
.
"
\n
"
;
}
}
public
function
acceptSequence
(
Sequence
$sequence
)
{
}
public
function
acceptTable
(
Table
$table
)
public
function
acceptTable
(
Table
$table
)
{
{
$this
->
output
.=
$this
->
createNode
(
$this
->
output
.=
$this
->
createNode
(
...
@@ -133,6 +120,16 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -133,6 +120,16 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
return
$relation
;
return
$relation
;
}
}
/**
* Get Graphviz Output
*
* @return string
*/
public
function
getOutput
()
{
return
$this
->
output
.
"}"
;
}
/**
/**
* Write dot language output to a file. This should usually be a *.dot file.
* Write dot language output to a file. This should usually be a *.dot file.
*
*
...
@@ -146,6 +143,6 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -146,6 +143,6 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
*/
*/
public
function
write
(
$filename
)
public
function
write
(
$filename
)
{
{
file_put_contents
(
$filename
,
$this
->
output
.
"}"
);
file_put_contents
(
$filename
,
$this
->
getOutput
()
);
}
}
}
}
lib/Doctrine/DBAL/Schema/Visitor/RemoveNamespacedAssets.php
View file @
5eea9913
...
@@ -22,11 +22,9 @@ namespace Doctrine\DBAL\Schema\Visitor;
...
@@ -22,11 +22,9 @@ namespace Doctrine\DBAL\Schema\Visitor;
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Column
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Sequence
,
Doctrine\DBAL\Schema\Sequence
;
Doctrine\DBAL\Schema\Index
;
/**
/**
* Remove assets from a schema that are not in the default namespace.
* Remove assets from a schema that are not in the default namespace.
...
@@ -42,7 +40,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
...
@@ -42,7 +40,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @since 2.2
* @since 2.2
*/
*/
class
RemoveNamespacedAssets
implements
Visitor
class
RemoveNamespacedAssets
extends
Abstract
Visitor
{
{
/**
/**
* @var Schema
* @var Schema
...
@@ -76,13 +74,6 @@ class RemoveNamespacedAssets implements Visitor
...
@@ -76,13 +74,6 @@ class RemoveNamespacedAssets implements Visitor
}
}
}
}
/**
* @param Column $column
*/
public
function
acceptColumn
(
Table
$table
,
Column
$column
)
{
}
/**
/**
* @param Table $localTable
* @param Table $localTable
* @param ForeignKeyConstraint $fkConstraint
* @param ForeignKeyConstraint $fkConstraint
...
@@ -102,12 +93,4 @@ class RemoveNamespacedAssets implements Visitor
...
@@ -102,12 +93,4 @@ class RemoveNamespacedAssets implements Visitor
$localTable
->
removeForeignKey
(
$fkConstraint
->
getName
());
$localTable
->
removeForeignKey
(
$fkConstraint
->
getName
());
}
}
}
}
/**
* @param Table $table
* @param Index $index
*/
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
{
}
}
}
lib/Doctrine/DBAL/Schema/Visitor/SchemaDiffVisitor.php
0 → 100644
View file @
5eea9913
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Schema\Visitor
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\TableDiff
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Sequence
,
Doctrine\DBAL\Schema\SchemaException
,
Doctrine\DBAL\Schema\Index
;
/**
* Visit a SchemaDiff.
*
* @link www.doctrine-project.org
* @since 2.4
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
interface
SchemaDiffVisitor
{
/**
* Visit an orphaned foreign key whose table was deleted.
*
* @param ForeignKeyConstraint $foreignKey
*/
function
visitOrphanedForeignKey
(
ForeignKeyConstraint
$foreignKey
);
/**
* Visit a sequence that has changed.
*
* @param Sequence $sequence
*/
function
visitChangedSequence
(
Sequence
$sequence
);
/**
* Visit a sequence that has been removed.
*
* @param Sequence $sequence
*/
function
visitRemovedSequence
(
Sequence
$sequence
);
function
visitNewSequence
(
Sequence
$sequence
);
function
visitNewTable
(
Table
$table
);
function
visitNewTableForeignKey
(
Table
$table
,
ForeignKeyConstraint
$foreignKey
);
function
visitRemovedTable
(
Table
$table
);
function
visitChangedTable
(
TableDiff
$tableDiff
);
}
lib/Doctrine/DBAL/Schema/Visitor/Visitor.php
View file @
5eea9913
...
@@ -21,14 +21,14 @@
...
@@ -21,14 +21,14 @@
namespace
Doctrine\DBAL\Schema\Visitor
;
namespace
Doctrine\DBAL\Schema\Visitor
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
Doctrine\DBAL\Schema\Table
,
use
Doctrine\DBAL\Schema\Table
;
Doctrine\DBAL\Schema\Schema
,
use
Doctrine\DBAL\Schema\Schema
;
Doctrine\DBAL\Schema\Column
,
use
Doctrine\DBAL\Schema\Column
;
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
use
Doctrine\DBAL\Schema\ForeignKeyConstraint
;
Doctrine\DBAL\Schema\Constraint
,
use
Doctrine\DBAL\Schema\Constraint
;
Doctrine\DBAL\Schema\Sequence
,
use
Doctrine\DBAL\Schema\Sequence
;
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\Index
;
/**
/**
* Schema Visitor used for Validation or Generation purposes.
* Schema Visitor used for Validation or Generation purposes.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment