Merge branch '3.4' into 4.3
* 3.4: [DoctrineBridge] try to fix deprecations from doctrine/persistence [Translation] fix memoryleak in PhpFileLoader
This commit is contained in:
commit
72936e457f
@ -11,7 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\CacheWarmer;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
|
||||
/**
|
||||
@ -26,7 +27,10 @@ class ProxyCacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
private $registry;
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
/**
|
||||
* @param ManagerRegistry|LegacyManagerRegistry $registry
|
||||
*/
|
||||
public function __construct($registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
|
@ -11,10 +11,11 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\DataCollector;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\DBAL\Logging\DebugStack;
|
||||
use Doctrine\DBAL\Types\ConversionException;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
|
||||
@ -35,7 +36,10 @@ class DoctrineDataCollector extends DataCollector
|
||||
*/
|
||||
private $loggers = [];
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
/**
|
||||
* @param ManagerRegistry|LegacyManagerRegistry $registry
|
||||
*/
|
||||
public function __construct($registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
$this->connections = $registry->getConnectionNames();
|
||||
|
@ -143,7 +143,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
|
||||
|
||||
$mappingDriverDef = $this->getDriver($container);
|
||||
$chainDriverDefService = $this->getChainDriverServiceName($container);
|
||||
// Definition for a Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain
|
||||
// Definition for a Doctrine\Persistence\Mapping\Driver\MappingDriverChain
|
||||
$chainDriverDef = $container->getDefinition($chainDriverDefService);
|
||||
foreach ($this->namespaces as $namespace) {
|
||||
$chainDriverDef->addMethodCall('addDriver', [$mappingDriverDef, $namespace]);
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
||||
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
@ -40,12 +41,12 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
|
||||
* passed which optimizes the object loading for one of the Doctrine
|
||||
* mapper implementations.
|
||||
*
|
||||
* @param ObjectManager $manager The object manager
|
||||
* @param string $class The class name of the loaded objects
|
||||
* @param IdReader|null $idReader The reader for the object IDs
|
||||
* @param EntityLoaderInterface|null $objectLoader The objects loader
|
||||
* @param ObjectManager|LegacyObjectManager $manager The object manager
|
||||
* @param string $class The class name of the loaded objects
|
||||
* @param IdReader $idReader The reader for the object IDs
|
||||
* @param EntityLoaderInterface|null $objectLoader The objects loader
|
||||
*/
|
||||
public function __construct(ObjectManager $manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
|
||||
public function __construct($manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
|
||||
{
|
||||
$classMetadata = $manager->getClassMetadata($class);
|
||||
|
||||
|
@ -11,8 +11,10 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata as LegacyClassMetadata;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\Form\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
@ -35,7 +37,11 @@ class IdReader
|
||||
*/
|
||||
private $associationIdReader;
|
||||
|
||||
public function __construct(ObjectManager $om, ClassMetadata $classMetadata)
|
||||
/**
|
||||
* @param ObjectManager|LegacyObjectManager $om
|
||||
* @param ClassMetadata|LegacyClassMetadata $classMetadata
|
||||
*/
|
||||
public function __construct($om, $classMetadata)
|
||||
{
|
||||
$ids = $classMetadata->getIdentifierFieldNames();
|
||||
$idType = $classMetadata->getTypeOfField(current($ids));
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractExtension;
|
||||
|
||||
@ -19,7 +20,10 @@ class DoctrineOrmExtension extends AbstractExtension
|
||||
{
|
||||
protected $registry;
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
/**
|
||||
* @param ManagerRegistry|LegacyManagerRegistry $registry
|
||||
*/
|
||||
public function __construct($registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
|
@ -11,12 +11,14 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException as LegacyCommonMappingException;
|
||||
use Doctrine\Common\Persistence\Proxy;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
use Symfony\Component\Form\FormTypeGuesserInterface;
|
||||
use Symfony\Component\Form\Guess\Guess;
|
||||
use Symfony\Component\Form\Guess\TypeGuess;
|
||||
@ -28,7 +30,10 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
|
||||
private $cache = [];
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
/**
|
||||
* @param ManagerRegistry|LegacyManagerRegistry $registry
|
||||
*/
|
||||
public function __construct($registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
@ -182,6 +187,8 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
return $this->cache[$class] = [$em->getClassMetadata($class), $name];
|
||||
} catch (MappingException $e) {
|
||||
// not an entity or mapped super class
|
||||
} catch (LegacyCommonMappingException $e) {
|
||||
// not an entity or mapped super class
|
||||
} catch (LegacyMappingException $e) {
|
||||
// not an entity or mapped super class, using Doctrine ORM 2.2
|
||||
}
|
||||
@ -192,10 +199,12 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
|
||||
private static function getRealClass(string $class): string
|
||||
{
|
||||
if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) {
|
||||
$marker = interface_exists(Proxy::class) ? '\\'.Proxy::MARKER.'\\' : '\__CG__\\';
|
||||
|
||||
if (false === $pos = strrpos($class, $marker)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
|
||||
return substr($class, $pos + \strlen($marker));
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,10 @@
|
||||
namespace Symfony\Bridge\Doctrine\Form\Type;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader;
|
||||
@ -101,7 +103,10 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
/**
|
||||
* @param ManagerRegistry|LegacyManagerRegistry $registry
|
||||
*/
|
||||
public function __construct($registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
@ -191,9 +196,8 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
|
||||
};
|
||||
|
||||
$emNormalizer = function (Options $options, $em) {
|
||||
/* @var ManagerRegistry $registry */
|
||||
if (null !== $em) {
|
||||
if ($em instanceof ObjectManager) {
|
||||
if ($em instanceof ObjectManager || $em instanceof LegacyObjectManager) {
|
||||
return $em;
|
||||
}
|
||||
|
||||
@ -263,7 +267,7 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
|
||||
$resolver->setNormalizer('query_builder', $queryBuilderNormalizer);
|
||||
$resolver->setNormalizer('id_reader', $idReaderNormalizer);
|
||||
|
||||
$resolver->setAllowedTypes('em', ['null', 'string', 'Doctrine\Common\Persistence\ObjectManager']);
|
||||
$resolver->setAllowedTypes('em', ['null', 'string', ObjectManager::class, LegacyObjectManager::class]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,7 +278,7 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
|
||||
*
|
||||
* @return EntityLoaderInterface
|
||||
*/
|
||||
abstract public function getLoader(ObjectManager $manager, $queryBuilder, $class);
|
||||
abstract public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class);
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form\Type;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Doctrine\ORM\Query\Parameter;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
|
||||
@ -51,7 +51,7 @@ class EntityType extends DoctrineType
|
||||
*
|
||||
* @return ORMQueryBuilderLoader
|
||||
*/
|
||||
public function getLoader(ObjectManager $manager, $queryBuilder, $class)
|
||||
public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class)
|
||||
{
|
||||
return new ORMQueryBuilderLoader($queryBuilder);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine;
|
||||
|
||||
use Doctrine\Common\Persistence\AbstractManagerRegistry;
|
||||
use Doctrine\Common\Persistence\AbstractManagerRegistry as LegacyAbstractManagerRegistry;
|
||||
use ProxyManager\Proxy\LazyLoadingInterface;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
@ -20,7 +20,7 @@ use Symfony\Component\DependencyInjection\Container;
|
||||
*
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
abstract class ManagerRegistry extends AbstractManagerRegistry
|
||||
abstract class ManagerRegistry extends LegacyAbstractManagerRegistry
|
||||
{
|
||||
/**
|
||||
* @var Container
|
||||
|
@ -11,13 +11,15 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\PropertyInfo;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory as LegacyClassMetadataFactory;
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException as LegacyMappingException;
|
||||
use Doctrine\DBAL\Types\Type as DBALType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
use Doctrine\ORM\Mapping\MappingException as OrmMappingException;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
|
||||
use Doctrine\Persistence\Mapping\MappingException;
|
||||
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
|
||||
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
|
||||
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
|
||||
@ -40,7 +42,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
||||
{
|
||||
if ($entityManager instanceof EntityManagerInterface) {
|
||||
$this->entityManager = $entityManager;
|
||||
} elseif ($entityManager instanceof ClassMetadataFactory) {
|
||||
} elseif ($entityManager instanceof ClassMetadataFactory || $entityManager instanceof LegacyClassMetadataFactory) {
|
||||
@trigger_error(sprintf('Injecting an instance of "%s" in "%s" is deprecated since Symfony 4.2, inject an instance of "%s" instead.', ClassMetadataFactory::class, __CLASS__, EntityManagerInterface::class), E_USER_DEPRECATED);
|
||||
$this->classMetadataFactory = $entityManager;
|
||||
} else {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as ManagerRegistryInterface;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
@ -19,7 +19,7 @@ use Doctrine\ORM\EntityManager;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface RegistryInterface extends ManagerRegistryInterface
|
||||
interface RegistryInterface extends LegacyManagerRegistry
|
||||
{
|
||||
/**
|
||||
* Gets the default entity manager name.
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Security\User;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
@ -33,7 +34,10 @@ class EntityUserProvider implements UserProviderInterface
|
||||
private $class;
|
||||
private $property;
|
||||
|
||||
public function __construct(ManagerRegistry $registry, string $classOrAlias, string $property = null, string $managerName = null)
|
||||
/**
|
||||
* @param ManagerRegistry|LegacyManagerRegistry $registry
|
||||
*/
|
||||
public function __construct($registry, string $classOrAlias, string $property = null, string $managerName = null)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
$this->managerName = $managerName;
|
||||
|
@ -13,12 +13,14 @@ namespace Symfony\Bridge\Doctrine\Test;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Cache\ArrayCache;
|
||||
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
|
||||
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator;
|
||||
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain as LegacyMappingDriverChain;
|
||||
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator as LegacySymfonyFileLocator;
|
||||
use Doctrine\ORM\Configuration;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
|
||||
use Doctrine\ORM\Mapping\Driver\XmlDriver;
|
||||
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
|
||||
use Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
@ -74,11 +76,13 @@ class DoctrineTestHelper
|
||||
public static function createTestConfigurationWithXmlLoader()
|
||||
{
|
||||
$config = static::createTestConfiguration();
|
||||
$symfonyFileLocator = class_exists(SymfonyFileLocator::class) ? SymfonyFileLocator::class : LegacySymfonyFileLocator::class;
|
||||
$driverChain = class_exists(MappingDriverChain::class) ? MappingDriverChain::class : LegacyMappingDriverChain::class;
|
||||
|
||||
$driverChain = new MappingDriverChain();
|
||||
$driverChain->addDriver(
|
||||
new XmlDriver(
|
||||
new SymfonyFileLocator(
|
||||
new $symfonyFileLocator(
|
||||
[__DIR__.'/../Tests/Resources/orm' => 'Symfony\\Bridge\\Doctrine\\Tests\\Fixtures'], '.orm.xml'
|
||||
)
|
||||
),
|
||||
|
@ -11,10 +11,11 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Test;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Common\Persistence\ObjectRepository as LegacyObjectRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Repository\RepositoryFactory;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
/**
|
||||
* @author Andreas Braun <alcaeus@alcaeus.org>
|
||||
@ -40,7 +41,7 @@ final class TestRepositoryFactory implements RepositoryFactory
|
||||
return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName);
|
||||
}
|
||||
|
||||
public function setRepository(EntityManagerInterface $entityManager, $entityName, ObjectRepository $repository)
|
||||
public function setRepository(EntityManagerInterface $entityManager, $entityName, LegacyObjectRepository $repository)
|
||||
{
|
||||
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);
|
||||
|
||||
@ -48,7 +49,7 @@ final class TestRepositoryFactory implements RepositoryFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ObjectRepository
|
||||
* @return ObjectRepository|LegacyObjectRepository
|
||||
*/
|
||||
private function createRepository(EntityManagerInterface $entityManager, string $entityName)
|
||||
{
|
||||
|
@ -11,8 +11,10 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Tests\DataCollector;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||
use Doctrine\DBAL\Version;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -180,7 +182,7 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
->method('getDatabasePlatform')
|
||||
->willReturn(new MySqlPlatform());
|
||||
|
||||
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$registry = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock();
|
||||
$registry
|
||||
->expects($this->any())
|
||||
->method('getConnectionNames')
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
|
||||
|
||||
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
@ -25,7 +25,7 @@ class ContainerAwareFixture implements FixtureInterface, ContainerAwareInterface
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
public function load(LegacyObjectManager $manager)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,11 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Doctrine\Common\Persistence\ObjectRepository as LegacyObjectRepository;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
|
||||
@ -76,8 +78,8 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
|
||||
$this->om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
|
||||
$this->repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
|
||||
$this->om = $this->getMockBuilder(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class)->getMock();
|
||||
$this->repository = $this->getMockBuilder(interface_exists(ObjectRepository::class) ? ObjectRepository::class : LegacyObjectRepository::class)->getMock();
|
||||
$this->class = 'stdClass';
|
||||
$this->idReader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -11,7 +11,11 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Form;
|
||||
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser;
|
||||
use Symfony\Component\Form\Guess\Guess;
|
||||
@ -83,10 +87,10 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
|
||||
private function getGuesser(ClassMetadata $classMetadata)
|
||||
{
|
||||
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
|
||||
$em = $this->getMockBuilder(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class)->getMock();
|
||||
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->willReturn($classMetadata);
|
||||
|
||||
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$registry = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock();
|
||||
$registry->expects($this->once())->method('getManagers')->willReturn([$em]);
|
||||
|
||||
return new DoctrineOrmTypeGuesser($registry);
|
||||
|
@ -11,7 +11,9 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Form\Type;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
|
||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
||||
@ -34,7 +36,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
|
||||
protected function getExtensions()
|
||||
{
|
||||
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$manager = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock();
|
||||
|
||||
$manager->expects($this->any())
|
||||
->method('getManager')
|
||||
|
@ -12,10 +12,11 @@
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Form\Type;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
|
||||
use Symfony\Bridge\Doctrine\Form\DoctrineOrmTypeGuesser;
|
||||
@ -1228,7 +1229,7 @@ class EntityTypeTest extends BaseTypeTest
|
||||
|
||||
protected function createRegistryMock($name, $em)
|
||||
{
|
||||
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$registry = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock();
|
||||
$registry->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo($name))
|
||||
|
@ -11,7 +11,11 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Security\User;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||
@ -177,7 +181,7 @@ class EntityUserProviderTest extends TestCase
|
||||
|
||||
private function getManager($em, $name = null)
|
||||
{
|
||||
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$manager = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock();
|
||||
$manager->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo($name))
|
||||
@ -188,7 +192,7 @@ class EntityUserProviderTest extends TestCase
|
||||
|
||||
private function getObjectManager($repository)
|
||||
{
|
||||
$em = $this->getMockBuilder('\Doctrine\Common\Persistence\ObjectManager')
|
||||
$em = $this->getMockBuilder(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class)
|
||||
->setMethods(['getClassMetadata', 'getRepository'])
|
||||
->getMockForAbstractClass();
|
||||
$em->expects($this->any())
|
||||
|
@ -12,11 +12,16 @@
|
||||
namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata as LegacyClassMetadata;
|
||||
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
|
||||
use Doctrine\Common\Persistence\ObjectRepository as LegacyObjectRepository;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||
use Symfony\Bridge\Doctrine\Test\TestRepositoryFactory;
|
||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
|
||||
@ -76,9 +81,9 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
protected function createRegistryMock(ObjectManager $em = null)
|
||||
protected function createRegistryMock($em = null)
|
||||
{
|
||||
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$registry = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock();
|
||||
$registry->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo(self::EM_NAME))
|
||||
@ -89,7 +94,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
protected function createRepositoryMock()
|
||||
{
|
||||
$repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')
|
||||
$repository = $this->getMockBuilder(interface_exists(ObjectRepository::class) ? ObjectRepository::class : LegacyObjectRepository::class)
|
||||
->setMethods(['findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName'])
|
||||
->getMock()
|
||||
;
|
||||
@ -99,7 +104,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
protected function createEntityManagerMock($repositoryMock)
|
||||
{
|
||||
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
|
||||
$em = $this->getMockBuilder(interface_exists(ObjectManager::class) ? ObjectManager::class : LegacyObjectManager::class)
|
||||
->getMock()
|
||||
;
|
||||
$em->expects($this->any())
|
||||
@ -107,7 +112,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->willReturn($repositoryMock)
|
||||
;
|
||||
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
|
||||
$classMetadata = $this->getMockBuilder(interface_exists(ClassMetadata::class) ? ClassMetadata::class : LegacyClassMetadata::class)->getMock();
|
||||
$classMetadata
|
||||
->expects($this->any())
|
||||
->method('hasField')
|
||||
@ -141,7 +146,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
return new UniqueEntityValidator($this->registry);
|
||||
}
|
||||
|
||||
private function createSchema(ObjectManager $em)
|
||||
private function createSchema($em)
|
||||
{
|
||||
$schemaTool = new SchemaTool($em);
|
||||
$schemaTool->createSchema([
|
||||
|
@ -11,9 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Validator\Constraints;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
@ -28,7 +27,10 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
{
|
||||
private $registry;
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
/**
|
||||
* @param ManagerRegistry|LegacyManagerRegistry $registry
|
||||
*/
|
||||
public function __construct($registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
@ -78,7 +80,6 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
$class = $em->getClassMetadata(\get_class($entity));
|
||||
/* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */
|
||||
|
||||
$criteria = [];
|
||||
$hasNullValue = false;
|
||||
@ -179,7 +180,7 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class, $value)
|
||||
private function formatWithIdentifiers($em, $class, $value)
|
||||
{
|
||||
if (!\is_object($value) || $value instanceof \DateTimeInterface) {
|
||||
return $this->formatValue($value, self::PRETTY_DATE);
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Validator;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Validator\ObjectInitializerInterface;
|
||||
|
||||
/**
|
||||
@ -23,7 +24,10 @@ class DoctrineInitializer implements ObjectInitializerInterface
|
||||
{
|
||||
protected $registry;
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
/**
|
||||
* @param ManagerRegistry|LegacyManagerRegistry $registry
|
||||
*/
|
||||
public function __construct($registry)
|
||||
{
|
||||
$this->registry = $registry;
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Controller;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
||||
@ -82,7 +83,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
|
||||
'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class,
|
||||
'templating' => '?'.EngineInterface::class,
|
||||
'twig' => '?'.Environment::class,
|
||||
'doctrine' => '?'.ManagerRegistry::class,
|
||||
'doctrine' => '?'.(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class),
|
||||
'form.factory' => '?'.FormFactoryInterface::class,
|
||||
'security.token_storage' => '?'.TokenStorageInterface::class,
|
||||
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Controller;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Fig\Link\GenericLinkProvider;
|
||||
use Fig\Link\Link;
|
||||
use Psr\Container\ContainerInterface;
|
||||
@ -336,11 +337,13 @@ trait ControllerTrait
|
||||
/**
|
||||
* Shortcut to return the Doctrine Registry service.
|
||||
*
|
||||
* @return ManagerRegistry|LegacyManagerRegistry
|
||||
*
|
||||
* @throws \LogicException If DoctrineBundle is not available
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
protected function getDoctrine(): ManagerRegistry
|
||||
protected function getDoctrine()
|
||||
{
|
||||
if (!$this->container->has('doctrine')) {
|
||||
throw new \LogicException('The DoctrineBundle is not registered in your application. Try running "composer require symfony/orm-pack".');
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Fig\Link\Link;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
@ -522,7 +524,7 @@ abstract class ControllerTraitTest extends TestCase
|
||||
|
||||
public function testGetDoctrine()
|
||||
{
|
||||
$doctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$doctrine = $this->getMockBuilder(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class)->getMock();
|
||||
|
||||
$container = new Container();
|
||||
$container->set('doctrine', $doctrine);
|
||||
|
@ -18,11 +18,25 @@ namespace Symfony\Component\Translation\Loader;
|
||||
*/
|
||||
class PhpFileLoader extends FileLoader
|
||||
{
|
||||
private static $cache = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function loadResource($resource)
|
||||
{
|
||||
return require $resource;
|
||||
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
|
||||
self::$cache = null;
|
||||
}
|
||||
|
||||
if (null === self::$cache) {
|
||||
return require $resource;
|
||||
}
|
||||
|
||||
if (isset(self::$cache[$resource])) {
|
||||
return self::$cache[$resource];
|
||||
}
|
||||
|
||||
return self::$cache[$resource] = require $resource;
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
'Doctrine\Common\Proxy\Proxy' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castCommonProxy'],
|
||||
'Doctrine\ORM\Proxy\Proxy' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castOrmProxy'],
|
||||
'Doctrine\ORM\PersistentCollection' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castPersistentCollection'],
|
||||
'Doctrine\Persistence\ObjectManager' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||
|
||||
'DOMException' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castException'],
|
||||
'DOMStringList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'],
|
||||
|
Reference in New Issue
Block a user