Skip to content
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

[All Bundles] - use EntityManagerInterface in place of concrete class #3339

Open
wants to merge 8 commits into
base: 6.x
Choose a base branch
from
2 changes: 1 addition & 1 deletion docs/bundles/adminlist-bundle/configuring-adminlists.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Bulk actions are actions that can be applied to multiple adminlist items at once
To add a bulk action, add the following lines to your adminlistConfigurator `__construct` method

```PHP
public function __construct(EntityManager $em, AclHelper $aclHelper = null)
public function __construct(EntityManagerInterface $em, AclHelper $aclHelper = null)
{
...
$bulkPath = array('path' => 'acmewebsitebundle_route_name', 'params' => array());
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/coding-standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This is based on the best practices described in the [Symfony Cookbook](http://s

* PHPDoc blocks should be added for all classes, methods and functions (@Param, @return, @throws)
* use "int" instead of "integer", "bool" instead of "boolean", PagePartRef[] instead of array(PagePartRef)
* use inline typecasting: /* @var EntityManager $em */ (be sure the "use" statement is also done at the top)
* use inline typecasting: /* @var EntityManagerInterface $em */ (be sure the "use" statement is also done at the top)
* classes in the PHPDoc blocks should not be fully namespaced, but imported (use) at the top
* @return should be removed, if the function doesn't return anything

Expand Down
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
2 changes: 0 additions & 2 deletions src/Kunstmaan/AdminBundle/Controller/ExceptionController.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 Kunstmaan\AdminBundle\AdminList\ExceptionAdminListConfigurator;
use Kunstmaan\AdminBundle\Entity\Exception;
use Kunstmaan\AdminListBundle\Controller\AbstractAdminListController;
Expand Down Expand Up @@ -56,7 +55,6 @@ public function toggleResolveAction(Request $request, Exception $model): Redirec
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 Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -20,9 +20,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
Loading
Loading