Introducing DisconnectedClassMetadataFactory that will replace the need for ClassMetadataReader
This commit is contained in:
parent
12c9ca971b
commit
5cfe9e1d94
@ -191,6 +191,20 @@ class ClassMetadataFactory
|
||||
$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
|
||||
* is still not loaded.
|
||||
@ -205,17 +219,8 @@ class ClassMetadataFactory
|
||||
}
|
||||
|
||||
$loaded = array();
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
$parentClasses = array_reverse($parentClasses);
|
||||
|
||||
$parentClasses = $this->_getParentClasses($name);
|
||||
$parentClasses[] = $name;
|
||||
|
||||
// Move down the hierarchy of parent classes, starting from the topmost class
|
||||
@ -354,7 +359,7 @@ class ClassMetadataFactory
|
||||
*
|
||||
* @param Doctrine\ORM\Mapping\ClassMetadata $class
|
||||
*/
|
||||
private function _completeIdGeneratorMapping(ClassMetadata $class)
|
||||
private function _completeIdGeneratorMapping(ClassMetadataInfo $class)
|
||||
{
|
||||
$idGenType = $class->generatorType;
|
||||
if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) {
|
||||
|
@ -25,7 +25,8 @@ use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console,
|
||||
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.
|
||||
@ -95,7 +96,8 @@ EOT
|
||||
{
|
||||
$em = $this->getHelper('em')->getEntityManager();
|
||||
|
||||
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
||||
$cmf = new DisconnectedClassMetadataFactory($em);
|
||||
$metadatas = $cmf->getAllMetadata();
|
||||
$metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
|
||||
|
||||
// Process destination directory
|
||||
|
59
lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php
Normal file
59
lib/Doctrine/ORM/Tools/DisconnectedClassMetadataFactory.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user