cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,53 +1,54 @@
<?php
/*
*/
namespace Chill\ThirdPartyBundle\Search;
use Chill\MainBundle\Search\SearchInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Symfony\Component\Security\Core\Role\Role;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\MainBundle\Pagination\PaginatorFactory;
/**
* Allow to search amongst parties
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ThirdPartyBundle\Search;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Search\SearchInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
/**
* Allow to search amongst parties.
*/
class ThirdPartySearch implements SearchInterface
{
public const NAME = '3party';
/**
*
* @var EntityManagerInterface
*/
protected $em;
/**
*
* @var TokenStorageInterface
*/
protected $tokenStorage;
/**
*
* @var AuthorizationHelper
*/
protected $authorizationHelper;
/**
*
* @var PaginatorFactory
* @var EntityManagerInterface
*/
protected $em;
/**
* @var PaginatorFactory
*/
protected $paginatorFactory;
const NAME = '3party';
/**
* @var TokenStorageInterface
*/
protected $tokenStorage;
public function __construct(
EntityManagerInterface $em,
TokenStorageInterface $tokenStorage,
AuthorizationHelper $authorizationHelper,
EntityManagerInterface $em,
TokenStorageInterface $tokenStorage,
AuthorizationHelper $authorizationHelper,
PaginatorFactory $paginatorFactory
) {
$this->em = $em;
@@ -56,7 +57,6 @@ class ThirdPartySearch implements SearchInterface
$this->paginatorFactory = $paginatorFactory;
}
public function getOrder(): int
{
return 59866;
@@ -67,34 +67,39 @@ class ThirdPartySearch implements SearchInterface
return false;
}
public function renderResult(array $terms, $start = 0, $limit = 50, $options = array(), $format = 'html')
public function renderResult(array $terms, $start = 0, $limit = 50, $options = [], $format = 'html')
{
$centers = $this->authorizationHelper
->getReachableCenters(
$this->tokenStorage->getToken()->getUser(),
$this->tokenStorage->getToken()->getUser(),
new Role(ThirdPartyVoter::SHOW)
);
);
$total = $this->count($centers, $terms);
$paginator = $this->paginatorFactory->create($total);
// replace types in terms by types in query
$terms['types'] = $options[SearchInterface::REQUEST_QUERY_PARAMETERS]['t'];
$terms['is_active'] = true;
if ($format === 'json') {
if ('json' === $format) {
return [
'results' => $this->em->getRepository(ThirdParty::class)
->findByMemberOfCenters($centers, $start, $limit, $terms,
['array', ['tp.id', 'tp.name AS text']]),
'more' => $paginator->hasNextPage()
->findByMemberOfCenters(
$centers,
$start,
$limit,
$terms,
['array', ['tp.id', 'tp.name AS text']]
),
'more' => $paginator->hasNextPage(),
];
}
}
public function supports($domain, $format): bool
{
return self::NAME === $domain and $format === 'json';
return self::NAME === $domain and 'json' === $format;
}
protected function count($centers, $terms): int
{
return $this->em->getRepository(ThirdParty::class)