From b76361feda0da4a6f4e79c3b2657f6ca50b4cf91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boutter=20Lo=C3=AFc?= Date: Thu, 9 Jan 2020 22:26:43 +0100 Subject: [PATCH] Use doctrine/bundle 2 (#1099) * use doctrine/bundle 2 * use doctrine/bundle 2 * Blacklist symfony/dependency-injection 4.4 * Symfony 3.4 compatibility * Fixed usage of RegistryInterface in tests * Add doctrine/persistence dependency * version constraint on doctrine/doctrine-bundle matching doctrine/persistence * version constraint of doctrine/doctrine-bundle Co-Authored-By: Javier Spagnoletti Co-authored-by: Javier Spagnoletti --- composer.json | 3 ++- src/Entity/BlockInteractor.php | 8 ++++---- src/Entity/Transformer.php | 6 +++--- tests/Model/BlockInteractorTest.php | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 8345c99ce..a10828ddd 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "require": { "php": "^7.1", "cocur/slugify": "^1.0 || ^2.0 || ^3.0", - "doctrine/doctrine-bundle": "^1.0", + "doctrine/doctrine-bundle": "^1.12.3 || ^2.0", + "doctrine/persistence": "^1.3.3", "sonata-project/admin-bundle": "^3.35", "sonata-project/block-bundle": "^3.18", "sonata-project/cache": "^1.0.2 || ^2.0", diff --git a/src/Entity/BlockInteractor.php b/src/Entity/BlockInteractor.php index dbace1ae1..5e166bf41 100644 --- a/src/Entity/BlockInteractor.php +++ b/src/Entity/BlockInteractor.php @@ -14,10 +14,10 @@ namespace Sonata\PageBundle\Entity; use Doctrine\ORM\EntityManager; +use Doctrine\Persistence\ManagerRegistry; use Sonata\BlockBundle\Model\BlockManagerInterface; use Sonata\PageBundle\Model\BlockInteractorInterface; use Sonata\PageBundle\Model\PageInterface; -use Symfony\Bridge\Doctrine\RegistryInterface; /** * This class interacts with blocks. @@ -32,7 +32,7 @@ class BlockInteractor implements BlockInteractorInterface protected $pageBlocksLoaded = []; /** - * @var RegistryInterface + * @var ManagerRegistry */ protected $registry; @@ -42,10 +42,10 @@ class BlockInteractor implements BlockInteractorInterface protected $blockManager; /** - * @param RegistryInterface $registry Doctrine registry + * @param ManagerRegistry $registry Doctrine registry * @param BlockManagerInterface $blockManager Block manager */ - public function __construct(RegistryInterface $registry, BlockManagerInterface $blockManager) + public function __construct(ManagerRegistry $registry, BlockManagerInterface $blockManager) { $this->blockManager = $blockManager; $this->registry = $registry; diff --git a/src/Entity/Transformer.php b/src/Entity/Transformer.php index 00470fb5f..ab0b086b3 100644 --- a/src/Entity/Transformer.php +++ b/src/Entity/Transformer.php @@ -15,6 +15,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\Persistence\ManagerRegistry; use Sonata\BlockBundle\Model\BlockInterface; use Sonata\BlockBundle\Model\BlockManagerInterface; use Sonata\PageBundle\Model\PageInterface; @@ -23,7 +24,6 @@ use Sonata\PageBundle\Model\SnapshotManagerInterface; use Sonata\PageBundle\Model\SnapshotPageProxy; use Sonata\PageBundle\Model\TransformerInterface; -use Symfony\Bridge\Doctrine\RegistryInterface; /** * This class transform a SnapshotInterface into PageInterface. @@ -51,11 +51,11 @@ class Transformer implements TransformerInterface protected $children = []; /** - * @var RegistryInterface + * @var ManagerRegistry */ protected $registry; - public function __construct(SnapshotManagerInterface $snapshotManager, PageManagerInterface $pageManager, BlockManagerInterface $blockManager, RegistryInterface $registry) + public function __construct(SnapshotManagerInterface $snapshotManager, PageManagerInterface $pageManager, BlockManagerInterface $blockManager, ManagerRegistry $registry) { $this->snapshotManager = $snapshotManager; $this->pageManager = $pageManager; diff --git a/tests/Model/BlockInteractorTest.php b/tests/Model/BlockInteractorTest.php index ebfe51f4e..b597e6d79 100644 --- a/tests/Model/BlockInteractorTest.php +++ b/tests/Model/BlockInteractorTest.php @@ -13,12 +13,12 @@ namespace Sonata\PageBundle\Tests\Model; +use Doctrine\Common\Persistence\ManagerRegistry; use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Model\Block; use Sonata\BlockBundle\Model\BlockInterface; use Sonata\BlockBundle\Model\BlockManagerInterface; use Sonata\PageBundle\Entity\BlockInteractor; -use Symfony\Bridge\Doctrine\RegistryInterface; /** * @author Vincent Composieux @@ -30,7 +30,7 @@ class BlockInteractorTest extends TestCase */ public function testCreateNewContainer() { - $registry = $this->createMock(RegistryInterface::class); + $registry = $this->createMock(ManagerRegistry::class); $blockManager = $this->createMock(BlockManagerInterface::class); $blockManager->expects($this->any())->method('create')->willReturn(new Block());