[DoctrineBridge] Updated the code to use the new registry
This commit is contained in:
parent
08285edef9
commit
a1784c2b97
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\CacheWarmer;
|
||||
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
|
||||
/**
|
||||
@ -29,9 +29,9 @@ class ProxyCacheWarmer implements CacheWarmerInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param RegistryInterface $registry A RegistryInterface instance
|
||||
* @param ManagerRegistry $registry A ManagerRegistry instance
|
||||
*/
|
||||
public function __construct(RegistryInterface $registry)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
@ -48,7 +48,7 @@ class ProxyCacheWarmer implements CacheWarmerInterface
|
||||
|
||||
public function warmUp($cacheDir)
|
||||
{
|
||||
foreach ($this->registry->getEntityManagers() as $em) {
|
||||
foreach ($this->registry->getManagers() as $em) {
|
||||
// we need the directory no matter the proxy cache generation strategy
|
||||
if (!is_dir($proxyCacheDir = $em->getConfiguration()->getProxyDir())) {
|
||||
if (false === @mkdir($proxyCacheDir, 0777, true)) {
|
||||
|
@ -11,11 +11,11 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\DataCollector;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Bridge\Doctrine\Logger\DbalLogger;
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
|
||||
/**
|
||||
* DoctrineDataCollector.
|
||||
@ -28,10 +28,10 @@ class DoctrineDataCollector extends DataCollector
|
||||
private $managers;
|
||||
private $logger;
|
||||
|
||||
public function __construct(RegistryInterface $registry, DbalLogger $logger = null)
|
||||
public function __construct(ManagerRegistry $registry, DbalLogger $logger = null)
|
||||
{
|
||||
$this->connections = $registry->getConnectionNames();
|
||||
$this->managers = $registry->getEntityManagerNames();
|
||||
$this->managers = $registry->getManagerNames();
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
@ -84,5 +84,4 @@ class DoctrineDataCollector extends DataCollector
|
||||
{
|
||||
return 'db';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,14 +11,14 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Form\AbstractExtension;
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
|
||||
class DoctrineOrmExtension extends AbstractExtension
|
||||
{
|
||||
protected $registry;
|
||||
|
||||
public function __construct(RegistryInterface $registry)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
|
@ -11,11 +11,11 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Form\FormTypeGuesserInterface;
|
||||
use Symfony\Component\Form\Guess\Guess;
|
||||
use Symfony\Component\Form\Guess\TypeGuess;
|
||||
use Symfony\Component\Form\Guess\ValueGuess;
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Doctrine\ORM\Mapping\MappingException;
|
||||
|
||||
class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
@ -24,7 +24,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
|
||||
private $cache;
|
||||
|
||||
public function __construct(RegistryInterface $registry)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
$this->cache = array();
|
||||
@ -122,7 +122,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
}
|
||||
|
||||
$this->cache[$class] = null;
|
||||
foreach ($this->registry->getEntityManagers() as $name => $em) {
|
||||
foreach ($this->registry->getManagers() as $name => $em) {
|
||||
try {
|
||||
return $this->cache[$class] = array($em->getClassMetadata($class), $name);
|
||||
} catch (MappingException $e) {
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form\Type;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList;
|
||||
use Symfony\Bridge\Doctrine\Form\EventListener\MergeCollectionListener;
|
||||
use Symfony\Bridge\Doctrine\Form\DataTransformer\EntitiesToArrayTransformer;
|
||||
@ -24,7 +24,7 @@ class EntityType extends AbstractType
|
||||
{
|
||||
protected $registry;
|
||||
|
||||
public function __construct(RegistryInterface $registry)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
@ -55,7 +55,7 @@ class EntityType extends AbstractType
|
||||
|
||||
if (!isset($options['choice_list'])) {
|
||||
$defaultOptions['choice_list'] = new EntityChoiceList(
|
||||
$this->registry->getEntityManager($options['em']),
|
||||
$this->registry->getManager($options['em']),
|
||||
$options['class'],
|
||||
$options['property'],
|
||||
$options['query_builder'],
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Validator\Constraints;
|
||||
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
@ -25,14 +25,14 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
class UniqueEntityValidator extends ConstraintValidator
|
||||
{
|
||||
/**
|
||||
* @var RegistryInterface
|
||||
* @var ManagerRegistry
|
||||
*/
|
||||
private $registry;
|
||||
|
||||
/**
|
||||
* @param RegistryInterface $registry
|
||||
* @param ManagerRegistry $registry
|
||||
*/
|
||||
public function __construct(RegistryInterface $registry)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
@ -55,9 +55,9 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if ($constraint->em) {
|
||||
$em = $this->registry->getEntityManager($constraint->em);
|
||||
$em = $this->registry->getManager($constraint->em);
|
||||
} else {
|
||||
$em = $this->registry->getEntityManagerForClass(get_class($entity));
|
||||
$em = $this->registry->getManagerForClass(get_class($entity));
|
||||
}
|
||||
|
||||
$className = $this->context->getCurrentClass();
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Validator;
|
||||
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Validator\ObjectInitializerInterface;
|
||||
use Doctrine\ORM\Proxy\Proxy;
|
||||
|
||||
@ -24,7 +24,7 @@ class EntityInitializer implements ObjectInitializerInterface
|
||||
{
|
||||
protected $registry;
|
||||
|
||||
public function __construct(RegistryInterface $registry)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
@ -32,7 +32,7 @@ class EntityInitializer implements ObjectInitializerInterface
|
||||
public function initialize($object)
|
||||
{
|
||||
if ($object instanceof Proxy) {
|
||||
$this->registry->getEntityManagerForClass(get_class($object))->getUnitOfWork()->initializeObject($object);
|
||||
$this->registry->getManagerForClass(get_class($object))->getUnitOfWork()->initializeObject($object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -620,9 +620,9 @@ class EntityTypeTest extends TypeTestCase
|
||||
|
||||
protected function createRegistryMock($name, $em)
|
||||
{
|
||||
$registry = $this->getMock('Symfony\Bridge\Doctrine\RegistryInterface');
|
||||
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
|
||||
$registry->expects($this->any())
|
||||
->method('getEntityManager')
|
||||
->method('getManager')
|
||||
->with($this->equalTo($name))
|
||||
->will($this->returnValue($em));
|
||||
|
||||
|
@ -31,9 +31,9 @@ class UniqueValidatorTest extends DoctrineOrmTestCase
|
||||
{
|
||||
protected function createRegistryMock($entityManagerName, $em)
|
||||
{
|
||||
$registry = $this->getMock('Symfony\Bridge\Doctrine\RegistryInterface');
|
||||
$registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
|
||||
$registry->expects($this->any())
|
||||
->method('getEntityManager')
|
||||
->method('getManager')
|
||||
->with($this->equalTo($entityManagerName))
|
||||
->will($this->returnValue($em));
|
||||
|
||||
|
Reference in New Issue
Block a user