Permalink
Browse files

refactored Doctrine Bridge

 * added a RegistryInterface

 * changed all classes to depend on the Registry instead of a specific EntityManager

This is more consistent as the validator already took the registry and this allows
to use any entity manager in Forms.
  • Loading branch information...
fabpot committed Jun 8, 2011
1 parent 8ef569c commit 6d959014bf89ae816d75e7cdcd4835fdeaef721f
@@ -11,7 +11,7 @@
namespace Symfony\Bundle\DoctrineBundle\CacheWarmer;
-use Symfony\Bundle\DoctrineBundle\Registry;
+use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
/**
@@ -29,9 +29,9 @@ class ProxyCacheWarmer implements CacheWarmerInterface
/**
* Constructor.
*
- * @param Registry $registry The Doctrine registry
+ * @param RegistryInterface $registry A RegistryInterface instance
*/
- public function __construct(Registry $registry)
+ public function __construct(RegistryInterface $registry)
{
$this->registry = $registry;
}
@@ -15,7 +15,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\DoctrineBundle\Logger\DbalLogger;
-use Symfony\Bundle\DoctrineBundle\Registry;
+use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* DoctrineDataCollector.
@@ -28,7 +28,7 @@ class DoctrineDataCollector extends DataCollector
private $managers;
private $logger;
- public function __construct(Registry $registry, DbalLogger $logger = null)
+ public function __construct(RegistryInterface $registry, DbalLogger $logger = null)
{
$this->connections = $registry->getConnectionNames();
$this->managers = $registry->getEntityManagerNames();
@@ -11,7 +11,7 @@
namespace Symfony\Bundle\DoctrineBundle\Mapping;
-use Symfony\Bundle\DoctrineBundle\Registry;
+use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Doctrine\ORM\Tools\EntityRepositoryGenerator;
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -31,9 +31,9 @@ class MetadataFactory
/**
* Constructor.
*
- * @param Registry $registry A Registry instance
+ * @param RegistryInterface $registry A RegistryInterface instance
*/
- public function __construct(Registry $registry)
+ public function __construct(RegistryInterface $registry)
{
$this->registry = $registry;
}
View
@@ -12,6 +12,7 @@
namespace Symfony\Bundle\DoctrineBundle;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Bridge\Doctrine\RegistryInterface;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\ORMException;
@@ -21,7 +22,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
-class Registry
+class Registry implements RegistryInterface
{
private $container;
private $connections;
@@ -203,7 +204,6 @@ public function getEntityManagerNames()
return $this->entityManagers;
}
-
/**
* Gets the EntityRepository for an entity.
*
View
@@ -49,12 +49,12 @@
<service id="form.type_guesser.doctrine" class="%form.type_guesser.doctrine.class%">
<tag name="form.type_guesser" />
- <argument type="service" id="doctrine.orm.entity_manager" />
+ <argument type="service" id="doctrine" />
</service>
<service id="form.type.entity" class="Symfony\Bridge\Doctrine\Form\Type\EntityType">
<tag name="form.type" alias="entity" />
- <argument type="service" id="doctrine.orm.entity_manager" />
+ <argument type="service" id="doctrine" />
</service>
<service id="doctrine.orm.configuration" class="%doctrine.orm.configuration.class%" abstract="true" public="false" />

0 comments on commit 6d95901

Please sign in to comment.