From 70c96548fd78f12938dca204394696feacdf70bf Mon Sep 17 00:00:00 2001 From: romanb Date: Fri, 12 Sep 2008 13:16:05 +0000 Subject: [PATCH] moved entitymanager and entityrepository --- lib/Doctrine/ClassMetadata.php | 2 +- lib/Doctrine/ClassMetadata/Factory.php | 2 +- lib/Doctrine/Connection/UnitOfWork.php | 2 +- lib/Doctrine/ORM/Collection.php | 4 ++-- lib/Doctrine/ORM/Entity.php | 2 +- lib/Doctrine/{ => ORM}/EntityManager.php | 6 +++--- lib/Doctrine/{ => ORM}/EntityRepository.php | 3 +-- lib/Doctrine/ORM/Exceptions/ORMException.php | 4 +--- lib/Doctrine/ORM/Id/AbstractIdGenerator.php | 2 +- lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php | 2 +- lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php | 2 +- lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php | 2 +- lib/Doctrine/Query.php | 2 +- lib/Doctrine/Query/SqlBuilder.php | 2 +- tests/lib/Doctrine_OrmTestCase.php | 2 +- tests/lib/Doctrine_OrmTestSuite.php | 2 +- tests/lib/mocks/Doctrine_EntityManagerMock.php | 2 +- 17 files changed, 20 insertions(+), 23 deletions(-) rename lib/Doctrine/{ => ORM}/EntityManager.php (99%) rename lib/Doctrine/{ => ORM}/EntityRepository.php (99%) diff --git a/lib/Doctrine/ClassMetadata.php b/lib/Doctrine/ClassMetadata.php index 677a06f5f..81966e37a 100644 --- a/lib/Doctrine/ClassMetadata.php +++ b/lib/Doctrine/ClassMetadata.php @@ -356,7 +356,7 @@ class Doctrine_ClassMetadata implements Doctrine_Common_Configurable, Serializab * @param string $entityName Name of the entity class the metadata info is used for. * @param Doctrine::ORM::Entitymanager $em */ - public function __construct($entityName, Doctrine_EntityManager $em) + public function __construct($entityName, Doctrine_ORM_EntityManager $em) { $this->_entityName = $entityName; $this->_rootEntityName = $entityName; diff --git a/lib/Doctrine/ClassMetadata/Factory.php b/lib/Doctrine/ClassMetadata/Factory.php index 465fb886a..9ee5bd972 100644 --- a/lib/Doctrine/ClassMetadata/Factory.php +++ b/lib/Doctrine/ClassMetadata/Factory.php @@ -51,7 +51,7 @@ class Doctrine_ClassMetadata_Factory * @param $conn The connection to use. * @param $driver The metadata driver to use. */ - public function __construct(Doctrine_EntityManager $em, $driver) + public function __construct(Doctrine_ORM_EntityManager $em, $driver) { $this->_em = $em; $this->_driver = $driver; diff --git a/lib/Doctrine/Connection/UnitOfWork.php b/lib/Doctrine/Connection/UnitOfWork.php index d5e95a8d8..eae509cd0 100644 --- a/lib/Doctrine/Connection/UnitOfWork.php +++ b/lib/Doctrine/Connection/UnitOfWork.php @@ -120,7 +120,7 @@ class Doctrine_Connection_UnitOfWork * * @param Doctrine_EntityManager $em */ - public function __construct(Doctrine_EntityManager $em) + public function __construct(Doctrine_ORM_EntityManager $em) { $this->_em = $em; //TODO: any benefit with lazy init? diff --git a/lib/Doctrine/ORM/Collection.php b/lib/Doctrine/ORM/Collection.php index 35043901f..5dfb70abc 100644 --- a/lib/Doctrine/ORM/Collection.php +++ b/lib/Doctrine/ORM/Collection.php @@ -130,7 +130,7 @@ class Doctrine_ORM_Collection implements Countable, IteratorAggregate, Serializa public function __construct($entityBaseType, $keyField = null) { $this->_entityBaseType = $entityBaseType; - $this->_em = Doctrine_EntityManager::getActiveEntityManager(); + $this->_em = Doctrine_ORM_EntityManager::getActiveEntityManager(); if ($keyField !== null) { if ( ! $this->_em->getClassMetadata($entityBaseType)->hasField($keyField)) { @@ -1018,7 +1018,7 @@ class Doctrine_ORM_Collection implements Countable, IteratorAggregate, Serializa */ public function unserialize($serialized) { - $manager = Doctrine_EntityManager::getActiveEntityManager(); + $manager = Doctrine_ORM_EntityManager::getActiveEntityManager(); $connection = $manager->getConnection(); $array = unserialize($serialized); diff --git a/lib/Doctrine/ORM/Entity.php b/lib/Doctrine/ORM/Entity.php index 384224798..d9b6612d9 100644 --- a/lib/Doctrine/ORM/Entity.php +++ b/lib/Doctrine/ORM/Entity.php @@ -204,7 +204,7 @@ abstract class Doctrine_ORM_Entity implements ArrayAccess, Serializable public function __construct() { $this->_entityName = get_class($this); - $this->_em = Doctrine_EntityManager::getActiveEntityManager(); + $this->_em = Doctrine_ORM_EntityManager::getActiveEntityManager(); $this->_class = $this->_em->getClassMetadata($this->_entityName); $this->_oid = self::$_index++; $this->_data = $this->_em->_getTmpEntityData(); diff --git a/lib/Doctrine/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php similarity index 99% rename from lib/Doctrine/EntityManager.php rename to lib/Doctrine/ORM/EntityManager.php index 3a2c74c86..31fbf4ff2 100644 --- a/lib/Doctrine/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -38,7 +38,7 @@ * @version $Revision$ * @author Roman Borschel */ -class Doctrine_EntityManager +class Doctrine_ORM_EntityManager { /** * IMMEDIATE: Flush occurs automatically after each operation that issues database @@ -498,7 +498,7 @@ class Doctrine_EntityManager if ($customRepositoryClassName !== null) { $repository = new $customRepositoryClassName($entityName, $metadata); } else { - $repository = new Doctrine_EntityRepository($entityName, $metadata); + $repository = new Doctrine_ORM_EntityRepository($entityName, $metadata); } $this->_repositories[$entityName] = $repository; @@ -715,7 +715,7 @@ class Doctrine_EntityManager $eventManager = new Doctrine_Common_EventManager(); } - $em = new Doctrine_EntityManager($conn, $name, $config, $eventManager); + $em = new Doctrine_ORM_EntityManager($conn, $name, $config, $eventManager); $em->activate(); return $em; diff --git a/lib/Doctrine/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php similarity index 99% rename from lib/Doctrine/EntityRepository.php rename to lib/Doctrine/ORM/EntityRepository.php index 1fb7b30d5..66eabe1a3 100644 --- a/lib/Doctrine/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -33,9 +33,8 @@ * @since 2.0 * @version $Revision$ * @author Roman Borschel - * @todo package:orm */ -class Doctrine_EntityRepository +class Doctrine_ORM_EntityRepository { protected $_entityName; protected $_em; diff --git a/lib/Doctrine/ORM/Exceptions/ORMException.php b/lib/Doctrine/ORM/Exceptions/ORMException.php index 99e6db428..f340d27a7 100644 --- a/lib/Doctrine/ORM/Exceptions/ORMException.php +++ b/lib/Doctrine/ORM/Exceptions/ORMException.php @@ -34,6 +34,4 @@ * @author Roman Borschel */ class Doctrine_ORM_Exceptions_ORMException extends Doctrine_Common_Exceptions_DoctrineException -{ - -} +{} diff --git a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php b/lib/Doctrine/ORM/Id/AbstractIdGenerator.php index 7d221eb64..37eae1b34 100644 --- a/lib/Doctrine/ORM/Id/AbstractIdGenerator.php +++ b/lib/Doctrine/ORM/Id/AbstractIdGenerator.php @@ -13,7 +13,7 @@ abstract class Doctrine_ORM_Id_AbstractIdGenerator protected $_em; - public function __construct(Doctrine_EntityManager $em) + public function __construct(Doctrine_ORM_EntityManager $em) { $this->_em = $em; } diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index 204b3dd62..b3c7660bf 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -66,7 +66,7 @@ abstract class Doctrine_ORM_Internal_Hydration_AbstractHydrator * * @param Doctrine_Connection|null $connection */ - public function __construct(Doctrine_EntityManager $em) + public function __construct(Doctrine_ORM_EntityManager $em) { $this->_em = $em; $this->_nullObject = Doctrine_ORM_Internal_Null::$INSTANCE; diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php index d63d9f0b9..bdfa4b9f1 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectDriver.php @@ -41,7 +41,7 @@ class Doctrine_ORM_Internal_Hydration_ObjectDriver /** The EntityManager */ private $_em; - public function __construct(Doctrine_EntityManager $em) + public function __construct(Doctrine_ORM_EntityManager $em) { $this->_nullObject = Doctrine_ORM_Internal_Null::$INSTANCE; $this->_em = $em; diff --git a/lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php b/lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php index 0f341d43c..1c5d36aec 100644 --- a/lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php @@ -74,7 +74,7 @@ abstract class Doctrine_ORM_Persisters_AbstractEntityPersister /** * Constructs a new EntityPersister. */ - public function __construct(Doctrine_EntityManager $em, Doctrine_ClassMetadata $classMetadata) + public function __construct(Doctrine_ORM_EntityManager $em, Doctrine_ClassMetadata $classMetadata) { $this->_em = $em; $this->_entityName = $classMetadata->getClassName(); diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index f240e8c80..b12f0e227 100755 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -93,7 +93,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract // End of Caching Stuff - public function __construct(Doctrine_EntityManager $entityManager) + public function __construct(Doctrine_ORM_EntityManager $entityManager) { $this->_entityManager = $entityManager; $this->_hydrator = new Doctrine_ORM_Internal_Hydration_StandardHydrator($entityManager); diff --git a/lib/Doctrine/Query/SqlBuilder.php b/lib/Doctrine/Query/SqlBuilder.php index c664f5f73..8a2450733 100755 --- a/lib/Doctrine/Query/SqlBuilder.php +++ b/lib/Doctrine/Query/SqlBuilder.php @@ -42,7 +42,7 @@ abstract class Doctrine_Query_SqlBuilder protected $_connection; - public static function fromConnection(Doctrine_EntityManager $entityManager) + public static function fromConnection(Doctrine_ORM_EntityManager $entityManager) { $connection = $entityManager->getConnection(); diff --git a/tests/lib/Doctrine_OrmTestCase.php b/tests/lib/Doctrine_OrmTestCase.php index f82c9e6e2..a6f529181 100644 --- a/tests/lib/Doctrine_OrmTestCase.php +++ b/tests/lib/Doctrine_OrmTestCase.php @@ -22,7 +22,7 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase 'user' => 'john', 'password' => 'wayne' ); - $em = Doctrine_EntityManager::create($connectionOptions, 'mockEM', $config, $eventManager); + $em = Doctrine_ORM_EntityManager::create($connectionOptions, 'mockEM', $config, $eventManager); $this->_em = $em; } $this->_em->activate(); diff --git a/tests/lib/Doctrine_OrmTestSuite.php b/tests/lib/Doctrine_OrmTestSuite.php index 15ae17e05..02a2dd637 100644 --- a/tests/lib/Doctrine_OrmTestSuite.php +++ b/tests/lib/Doctrine_OrmTestSuite.php @@ -17,7 +17,7 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite 'user' => 'john', 'password' => 'wayne' ); - $em = Doctrine_EntityManager::create($connectionOptions, 'mockEM', $config, $eventManager); + $em = Doctrine_ORM_EntityManager::create($connectionOptions, 'mockEM', $config, $eventManager); $this->sharedFixture['em'] = $em; } diff --git a/tests/lib/mocks/Doctrine_EntityManagerMock.php b/tests/lib/mocks/Doctrine_EntityManagerMock.php index f91c1a95a..11d0d3581 100644 --- a/tests/lib/mocks/Doctrine_EntityManagerMock.php +++ b/tests/lib/mocks/Doctrine_EntityManagerMock.php @@ -2,7 +2,7 @@ require_once 'lib/mocks/Doctrine_EntityPersisterMock.php'; -class Doctrine_EntityManagerMock extends Doctrine_EntityManager +class Doctrine_EntityManagerMock extends Doctrine_ORM_EntityManager { private $_persisterMock;