-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[DoctrineBridge] try to fix deprecations from doctrine/persistence #34949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,10 @@ | |
|
||
namespace Symfony\Bridge\Doctrine\Form\Type; | ||
|
||
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; | ||
10000
|
@@ -99,7 +101,10 @@ public function getQueryBuilderPartsForCachingHash($queryBuilder) | |
return false; | ||
} | ||
|
||
public function __construct(ManagerRegistry $registry) | ||
/** | ||
* @param ManagerRegistry|LegacyManagerRegistry $registry | ||
*/ | ||
public function __construct($registry) | ||
{ | ||
$this->registry = $registry; | ||
} | ||
|
@@ -194,9 +199,8 @@ public function configureOptions(OptionsResolver $resolver) | |
}; | ||
|
||
$emNormalizer = function (Options $options, $em) { | ||
/* @var ManagerRegistry $registry */ | ||
if (null !== $em) { | ||
if ($em instanceof ObjectManager) { | ||
if ($em instanceof ObjectManager || $em instanceof LegacyObjectManager) { | ||
return $em; | ||
} | ||
|
||
|
@@ -262,7 +266,7 @@ public function configureOptions(OptionsResolver $resolver) | |
$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]); | ||
} | ||
|
||
/** | ||
|
@@ -273,7 +277,7 @@ public function configureOptions(OptionsResolver $resolver) | |
* | ||
* @return EntityLoaderInterface | ||
*/ | ||
abstract public function getLoader(ObjectManager $manager, $queryBuilder, $class); | ||
abstract public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class); | ||
|
||
public function getParent() | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 @@ public function configureOptions(OptionsResolver $resolver) | |
* | ||
* @return ORMQueryBuilderLoader | ||
*/ | ||
public function getLoader(ObjectManager $manager, $queryBuilder, $class) | ||
public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changing the type would be a BC break |
||
{ | ||
return new ORMQueryBuilderLoader($queryBuilder); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
|
@@ -22,7 +22,7 @@ | |
* | ||
* @author Lukas Kahwe Smith <smith@pooteeweet.org> | ||
*/ | ||
abstract class ManagerRegistry extends AbstractManagerRegistry implements ContainerAwareInterface | ||
abstract class ManagerRegistry extends LegacyAbstractManagerRegistry implements ContainerAwareInterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changing the type would be a BC break |
||
{ | ||
/** | ||
* @var Container | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,15 @@ | |
|
||
namespace Symfony\Bridge\Doctrine; | ||
|
||
use Doctrine\Common\Persistence\ManagerRegistry as ManagerRegistryInterface; | ||
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; | ||
use Doctrine\ORM\EntityManager; | ||
|
||
/** | ||
* References Doctrine connections and entity managers. | ||
* | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
interface RegistryInterface extends ManagerRegistryInterface | ||
interface RegistryInterface extends LegacyManagerRegistry | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changing the type would be a BC break |
||
{ | ||
/** | ||
* Gets the default entity manager name. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,15 +41,15 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName | |
return $this->repositoryList[$repositoryHash] = $this->createRepository($entityManager, $entityName); | ||
} | ||
|
||
public function setRepository(EntityManagerInterface $entityManager, $entityName, ObjectRepository $repository) | ||
public function setRepository(EntityManagerInterface $entityManager, $entityName, LegacyObjectRepository $repository) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changing the type would be a BC break |
||
{ | ||
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName); | ||
|
||
$this->repositoryList[$repositoryHash] = $repository; | ||
} | ||
|
||
/** | ||
* @return ObjectRepository | ||
* @return ObjectRepository|LegacyObjectRepository | ||
*/ | ||
private function createRepository(EntityManagerInterface $entityManager, $entityName) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing the type would be a BC break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it really? It's a class alias, so they are the same thing, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not when v1.2 is checked out