mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
DX: fix phpstan errors
This commit is contained in:
@@ -33,9 +33,8 @@ final class ThirdPartyRepository implements ObjectRepository
|
||||
/**
|
||||
* count amongst parties associated to $centers, with $terms parameters.
|
||||
*
|
||||
* @param type $terms
|
||||
*/
|
||||
public function countByMemberOfCenters(array $centers, $terms = []): int
|
||||
public function countByMemberOfCenters(array $centers, array $terms = []): int
|
||||
{
|
||||
$qb = $this->buildQuery($centers, $terms);
|
||||
$qb->select('COUNT(tp)');
|
||||
|
@@ -15,6 +15,7 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Search\SearchInterface;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
@@ -47,16 +48,20 @@ class ThirdPartySearch implements SearchInterface
|
||||
*/
|
||||
protected $tokenStorage;
|
||||
|
||||
private ThirdPartyRepository $thirdPartyRepository;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
PaginatorFactory $paginatorFactory
|
||||
PaginatorFactory $paginatorFactory,
|
||||
ThirdPartyRepository $thirdPartyRepository
|
||||
) {
|
||||
$this->em = $em;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
$this->thirdPartyRepository = $thirdPartyRepository;
|
||||
}
|
||||
|
||||
public function getOrder(): int
|
||||
@@ -74,7 +79,7 @@ class ThirdPartySearch implements SearchInterface
|
||||
$centers = $this->authorizationHelper
|
||||
->getReachableCenters(
|
||||
$this->tokenStorage->getToken()->getUser(),
|
||||
new Role(ThirdPartyVoter::SHOW)
|
||||
ThirdPartyVoter::SHOW
|
||||
);
|
||||
$total = $this->count($centers, $terms);
|
||||
$paginator = $this->paginatorFactory->create($total);
|
||||
@@ -84,7 +89,7 @@ class ThirdPartySearch implements SearchInterface
|
||||
|
||||
if ('json' === $format) {
|
||||
return [
|
||||
'results' => $this->em->getRepository(ThirdParty::class)
|
||||
'results' => $this->thirdPartyRepository
|
||||
->findByMemberOfCenters(
|
||||
$centers,
|
||||
$start,
|
||||
@@ -104,7 +109,7 @@ class ThirdPartySearch implements SearchInterface
|
||||
|
||||
protected function count($centers, $terms): int
|
||||
{
|
||||
return $this->em->getRepository(ThirdParty::class)
|
||||
return $this->thirdPartyRepository
|
||||
->countByMemberOfCenters($centers, $terms);
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
services:
|
||||
Chill\ThirdPartyBundle\Search\ThirdPartySearch:
|
||||
arguments:
|
||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
||||
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
|
||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||
$paginatorFactory: '@Chill\MainBundle\Pagination\PaginatorFactory'
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: 'chill.search', alias: '3party' }
|
||||
|
||||
|
Reference in New Issue
Block a user