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
5cfe9e1d
Commit
5cfe9e1d
authored
Apr 13, 2010
by
Jonathan H. Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introducing DisconnectedClassMetadataFactory that will replace the need for ClassMetadataReader
parent
12c9ca97
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
14 deletions
+80
-14
ClassMetadataFactory.php
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
+17
-12
GenerateEntitiesCommand.php
...ine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php
+4
-2
DisconnectedClassMetadataFactory.php
lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php
+59
-0
No files found.
lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
View file @
5cfe9e1d
...
@@ -191,6 +191,20 @@ class ClassMetadataFactory
...
@@ -191,6 +191,20 @@ class ClassMetadataFactory
$this
->
_loadedMetadata
[
$className
]
=
$class
;
$this
->
_loadedMetadata
[
$className
]
=
$class
;
}
}
protected
function
_getParentClasses
(
$name
)
{
// Collect parent classes, ignoring transient (not-mapped) classes.
//TODO: Evaluate whether we can use class_parents() here.
$parentClass
=
$name
;
$parentClasses
=
array
();
while
(
$parentClass
=
get_parent_class
(
$parentClass
))
{
if
(
!
$this
->
_driver
->
isTransient
(
$parentClass
))
{
$parentClasses
[]
=
$parentClass
;
}
}
return
array_reverse
(
$parentClasses
);
}
/**
/**
* Loads the metadata of the class in question and all it's ancestors whose metadata
* Loads the metadata of the class in question and all it's ancestors whose metadata
* is still not loaded.
* is still not loaded.
...
@@ -205,17 +219,8 @@ class ClassMetadataFactory
...
@@ -205,17 +219,8 @@ class ClassMetadataFactory
}
}
$loaded
=
array
();
$loaded
=
array
();
// Collect parent classes, ignoring transient (not-mapped) classes.
$parentClasses
=
$this
->
_getParentClasses
(
$name
);
//TODO: Evaluate whether we can use class_parents() here.
$parentClass
=
$name
;
$parentClasses
=
array
();
while
(
$parentClass
=
get_parent_class
(
$parentClass
))
{
if
(
!
$this
->
_driver
->
isTransient
(
$parentClass
))
{
$parentClasses
[]
=
$parentClass
;
}
}
$parentClasses
=
array_reverse
(
$parentClasses
);
$parentClasses
[]
=
$name
;
$parentClasses
[]
=
$name
;
// Move down the hierarchy of parent classes, starting from the topmost class
// Move down the hierarchy of parent classes, starting from the topmost class
...
@@ -354,7 +359,7 @@ class ClassMetadataFactory
...
@@ -354,7 +359,7 @@ class ClassMetadataFactory
*
*
* @param Doctrine\ORM\Mapping\ClassMetadata $class
* @param Doctrine\ORM\Mapping\ClassMetadata $class
*/
*/
private
function
_completeIdGeneratorMapping
(
ClassMetadata
$class
)
private
function
_completeIdGeneratorMapping
(
ClassMetadata
Info
$class
)
{
{
$idGenType
=
$class
->
generatorType
;
$idGenType
=
$class
->
generatorType
;
if
(
$idGenType
==
ClassMetadata
::
GENERATOR_TYPE_AUTO
)
{
if
(
$idGenType
==
ClassMetadata
::
GENERATOR_TYPE_AUTO
)
{
...
...
lib/Doctrine/ORM/Tools/Console/Command/GenerateEntitiesCommand.php
View file @
5cfe9e1d
...
@@ -25,7 +25,8 @@ use Symfony\Components\Console\Input\InputArgument,
...
@@ -25,7 +25,8 @@ use Symfony\Components\Console\Input\InputArgument,
Symfony\Components\Console\Input\InputOption
,
Symfony\Components\Console\Input\InputOption
,
Symfony\Components\Console
,
Symfony\Components\Console
,
Doctrine\ORM\Tools\Console\MetadataFilter
,
Doctrine\ORM\Tools\Console\MetadataFilter
,
Doctrine\ORM\Tools\EntityGenerator
;
Doctrine\ORM\Tools\EntityGenerator
,
Doctrine\ORM\Tools\DisconnectedClassMetadataFactory
;
/**
/**
* Command to generate entity classes and method stubs from your mapping information.
* Command to generate entity classes and method stubs from your mapping information.
...
@@ -95,7 +96,8 @@ EOT
...
@@ -95,7 +96,8 @@ EOT
{
{
$em
=
$this
->
getHelper
(
'em'
)
->
getEntityManager
();
$em
=
$this
->
getHelper
(
'em'
)
->
getEntityManager
();
$metadatas
=
$em
->
getMetadataFactory
()
->
getAllMetadata
();
$cmf
=
new
DisconnectedClassMetadataFactory
(
$em
);
$metadatas
=
$cmf
->
getAllMetadata
();
$metadatas
=
MetadataFilter
::
filter
(
$metadatas
,
$input
->
getOption
(
'filter'
));
$metadatas
=
MetadataFilter
::
filter
(
$metadatas
,
$input
->
getOption
(
'filter'
));
// Process destination directory
// Process destination directory
...
...
lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php
0 → 100644
View file @
5cfe9e1d
<?php
/*
* $Id$
*
* 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 LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\ORM\Tools
;
use
Doctrine\ORM\Mapping\ClassMetadataFactory
;
use
Doctrine\ORM\Mapping\ClassMetadataInfo
;
/**
* The ClassMetadataFactory is used to create ClassMetadataInfo objects
* that do not require the entity class actually exist. This allows us to
* load some mapping information and use it to do things like generate code
* from the mapping information.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class
DisconnectedClassMetadataFactory
extends
ClassMetadataFactory
{
/**
* @override
*/
protected
function
_newClassMetadataInstance
(
$className
)
{
return
new
ClassMetadataInfo
(
$className
);
}
/**
* @override
*/
protected
function
_getParentClasses
(
$name
)
{
return
array
();
}
}
\ No newline at end of file
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