Skip to content

Commit

Permalink
[All Bundles] - use EntityManagerInterface in place of concrete class
Browse files Browse the repository at this point in the history
  • Loading branch information
delboy1978uk committed Feb 28, 2024
1 parent c4810d7 commit 16f93d8
Show file tree
Hide file tree
Showing 95 changed files with 249 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\AdminList;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use Kunstmaan\AdminBundle\Entity\Exception;
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
Expand All @@ -13,7 +13,7 @@

class ExceptionAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
{
public function __construct(EntityManager $em, AclHelper $aclHelper = null)
public function __construct(EntityManagerInterface $em, AclHelper $aclHelper = null)
{
parent::__construct($em, $aclHelper);
}
Expand Down
2 changes: 0 additions & 2 deletions src/Kunstmaan/AdminBundle/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Kunstmaan\AdminBundle\Controller;

use Doctrine\ORM\EntityManager;
use Doctrine\Persistence\ManagerRegistry;
use Kunstmaan\AdminBundle\Entity\DashboardConfiguration;
use Kunstmaan\AdminBundle\FlashMessages\FlashTypes;
Expand Down Expand Up @@ -59,7 +58,6 @@ public function indexAction(): Response
#[Route(path: '/adminindex', name: 'KunstmaanAdminBundle_homepage_admin')]
public function editIndexAction(Request $request): Response
{
/* @var $em EntityManager */
$em = $this->managerRegistry->getManager();

/* @var DashboardConfiguration $dashboardConfiguration */
Expand Down
3 changes: 1 addition & 2 deletions src/Kunstmaan/AdminBundle/Controller/ExceptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Controller;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\AdminList\ExceptionAdminListConfigurator;
use Kunstmaan\AdminBundle\Entity\Exception;
use Kunstmaan\AdminListBundle\Controller\AbstractAdminListController;
Expand Down Expand Up @@ -62,7 +62,6 @@ public function toggleResolveAction(Request $request, Exception $model)
return new RedirectResponse($this->generateUrl('kunstmaanadminbundle_admin_exception'));
}

/* @var EntityManager $em */
$em = $this->getEntityManager();

$this->getAdminListConfigurator();
Expand Down
6 changes: 3 additions & 3 deletions src/Kunstmaan/AdminBundle/Helper/CloneHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Helper;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Event\DeepCloneAndSaveEvent;
use Kunstmaan\AdminBundle\Event\Events;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand All @@ -13,7 +13,7 @@
class CloneHelper
{
/**
* @var EntityManager
* @var EntityManagerInterface
*/
private $em;

Expand All @@ -22,7 +22,7 @@ class CloneHelper
*/
private $eventDispatcher;

public function __construct(EntityManager $em, EventDispatcherInterface $eventDispatcher)
public function __construct(EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher)
{
$this->em = $em;
$this->eventDispatcher = $eventDispatcher;
Expand Down
4 changes: 2 additions & 2 deletions src/Kunstmaan/AdminBundle/Helper/FormWidgets/FormWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Helper\FormWidgets;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Helper\FormHelper;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
Expand Down Expand Up @@ -76,7 +76,7 @@ public function bindRequest(Request $request)
{
}

public function persist(EntityManager $em)
public function persist(EntityManagerInterface $em)
{
foreach ($this->data as $item) {
$em->persist($item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Helper\FormWidgets;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\TabInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
Expand All @@ -21,9 +21,9 @@ public function buildForm(FormBuilderInterface $builder);
public function bindRequest(Request $request);

/**
* @param EntityManager $em The entity manager
* @param EntityManagerInterface $em The entity manager
*/
public function persist(EntityManager $em);
public function persist(EntityManagerInterface $em);

/**
* @return array
Expand Down
6 changes: 3 additions & 3 deletions src/Kunstmaan/AdminBundle/Helper/FormWidgets/ListWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Helper\FormWidgets;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -49,9 +49,9 @@ public function bindRequest(Request $request)
}

/**
* @param EntityManager $em The entity manager
* @param EntityManagerInterfacer $em The entity manager
*/
public function persist(EntityManager $em)
public function persist(EntityManagerInterface $em)
{
foreach ($this->widgets as $widget) {
$widget->persist($em);
Expand Down
4 changes: 2 additions & 2 deletions src/Kunstmaan/AdminBundle/Helper/FormWidgets/Tabs/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Helper\FormHelper;
use Kunstmaan\AdminBundle\Helper\FormWidgets\FormWidget;
use Symfony\Component\Form\FormBuilderInterface;
Expand Down Expand Up @@ -92,7 +92,7 @@ public function bindRequest(Request $request)
$this->widget->bindRequest($request);
}

public function persist(EntityManager $em)
public function persist(EntityManagerInterface $em)
{
$this->widget->persist($em);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Kunstmaan/AdminBundle/Helper/FormWidgets/Tabs/TabPane.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\UtilitiesBundle\Helper\Slugifier;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Form;
Expand Down Expand Up @@ -93,9 +93,9 @@ public function bindRequest(Request $request)
}

/**
* @param EntityManager $em The entity manager
* @param EntityManagerInterface $em The entity manager
*/
public function persist(EntityManager $em)
public function persist(EntityManagerInterface $em)
{
foreach ($this->tabs as $tab) {
$tab->persist($em);
Expand Down
6 changes: 3 additions & 3 deletions src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Helper\Security\Acl;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\QuoteStrategy;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\Parameter;
Expand Down Expand Up @@ -47,11 +47,11 @@ class AclHelper
private $permissionsEnabled;

/**
* @param EntityManager $em The entity manager
* @param EntityManagerInterface $em The entity manager
* @param TokenStorageInterface $tokenStorage The security token storage
* @param RoleHierarchyInterface $rh The role hierarchies
*/
public function __construct(EntityManager $em, TokenStorageInterface $tokenStorage, RoleHierarchyInterface $rh, $permissionsEnabled = true)
public function __construct(EntityManagerInterface $em, TokenStorageInterface $tokenStorage, RoleHierarchyInterface $rh, $permissionsEnabled = true)
{
$this->em = $em;
$this->tokenStorage = $tokenStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Kunstmaan\AdminBundle\Helper\Security\Acl;

use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Helper\Security\Acl\Permission\MaskBuilder;
use Kunstmaan\AdminBundle\Helper\Security\Acl\Permission\PermissionDefinition;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
Expand All @@ -18,7 +18,7 @@
class AclNativeHelper
{
/**
* @var EntityManager
* @var EntityManagerInterface
*/
private $em;

Expand All @@ -38,11 +38,11 @@ class AclNativeHelper
private $permissionsEnabled;

/**
* @param EntityManager $em The entity manager
* @param EntityManagerInterface $em The entity manager
* @param TokenStorageInterface $tokenStorage The security context
* @param RoleHierarchyInterface $rh The role hierarchies
*/
public function __construct(EntityManager $em, TokenStorageInterface $tokenStorage, RoleHierarchyInterface $rh, $permissionsEnabled = true)
public function __construct(EntityManagerInterface $em, TokenStorageInterface $tokenStorage, RoleHierarchyInterface $rh, $permissionsEnabled = true)
{
$this->em = $em;
$this->tokenStorage = $tokenStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Helper\Security\Acl\Permission;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Entity\AbstractEntity;
use Kunstmaan\AdminBundle\Entity\AclChangeset;
use Kunstmaan\AdminBundle\Entity\BaseUser;
Expand Down Expand Up @@ -36,7 +36,7 @@ class PermissionAdmin
protected $resource;

/**
* @var EntityManager
* @var EntityManagerInterface
*/
protected $em;

Expand Down Expand Up @@ -81,7 +81,7 @@ class PermissionAdmin
protected $shellHelper;

/**
* @param EntityManager $em The EntityManager
* @param EntityManagerInterface $em The EntityManager
* @param TokenStorageInterface $tokenStorage The token storage
* @param AclProviderInterface $aclProvider The ACL provider
* @param ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy The object retrieval strategy
Expand All @@ -90,7 +90,7 @@ class PermissionAdmin
* @param KernelInterface $kernel The kernel
*/
public function __construct(
EntityManager $em,
EntityManagerInterface $em,
TokenStorageInterface $tokenStorage,
AclProviderInterface $aclProvider,
ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Tests\Helper\FormWidgets;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Entity\User;
use Kunstmaan\AdminBundle\Helper\FormWidgets\FormWidget;
use PHPUnit\Framework\TestCase;
Expand All @@ -16,7 +16,7 @@ class FormWidgetTest extends TestCase
public function testWidget()
{
$builder = $this->createMock(FormBuilder::class);
$em = $this->createMock(EntityManager::class);
$em = $this->createMock(EntityManagerInterface::class);
$em->expects($this->once())->method('persist')->willReturn(new User());
$builder->expects($this->once())->method('getData');
$builder->expects($this->atLeastOnce())->method('add');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Tests\Helper\FormWidgets;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Helper\FormWidgets\FormWidget;
use Kunstmaan\AdminBundle\Helper\FormWidgets\ListWidget;
use PHPUnit\Framework\TestCase;
Expand All @@ -19,7 +19,7 @@ public function testWidget()

$widget = $this->createMock(FormWidget::class);
$builder = $this->createMock(FormBuilder::class);
$em = $this->createMock(EntityManager::class);
$em = $this->createMock(EntityManagerInterface::class);

$widget->expects($this->exactly(2))->method('bindRequest')->willReturn(true);
$widget->expects($this->exactly(2))->method('persist')->willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Kunstmaan\AdminBundle\Tests\Helper\FormWidgets\Tabs;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\AdminBundle\Helper\FormHelper;
use Kunstmaan\AdminBundle\Helper\FormWidgets\FormWidget;
use Kunstmaan\AdminBundle\Helper\FormWidgets\Tabs\Tab;
Expand All @@ -18,7 +18,7 @@ class TabTest extends TestCase
*/
public function testTab()
{
$em = $this->createMock(EntityManager::class);
$em = $this->createMock(EntityManagerInterface::class);
$builder = $this->createMock(FormBuilder::class);
$view = $this->createMock(FormView::class);
$widget = $this->createMock(FormWidget::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Result;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\QuoteStrategy;
use Doctrine\ORM\NativeQuery;
Expand All @@ -26,7 +26,7 @@
class AclHelperTest extends TestCase
{
/**
* @var EntityManager
* @var EntityManagerInterface
*/
protected $em;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Kunstmaan\AdminBundle\Entity\User;
use Kunstmaan\AdminBundle\Entity\UserInterface;
Expand All @@ -21,7 +21,7 @@
class AclNativeHelperTest extends TestCase
{
/**
* @var EntityManager
* @var EntityManagerInterface
*/
protected $em;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\QuoteStrategy;
use Doctrine\ORM\Query;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function testWalker()
$conn = $this->createMock(Connection::class);
$conn->expects($this->any())->method('getDatabasePlatform')->willReturn($platform);

$em = $this->createMock(EntityManager::class);
$em = $this->createMock(EntityManagerInterface::class);
$query = $this->createMock(AbstractQuery::class);
$mapping = $this->createMock(ResultSetMapping::class);
$result = $this->createMock(ParserResult::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Kunstmaan\AdminBundle\Tests\Helper\Security\Acl\Permission;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Kunstmaan\AdminBundle\Entity\AbstractEntity;
use Kunstmaan\AdminBundle\Entity\Role;
Expand Down Expand Up @@ -143,7 +143,7 @@ public function testCreateAclChangeset()
/**
* Return entity manager mock
*/
public function getEntityManager(): EntityManager
public function getEntityManager(): EntityManagerInterface
{
return $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor()
Expand Down
Loading

0 comments on commit 16f93d8

Please sign in to comment.