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,25 +1,39 @@
<?php
/**
* 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\PersonBundle\Search;
use Chill\MainBundle\Search\SearchApiInterface;
use Chill\MainBundle\Search\SearchApiQuery;
use Chill\MainBundle\Search\Utils\ExtractDateFromPattern;
use Chill\MainBundle\Search\Utils\ExtractPhonenumberFromPattern;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\MainBundle\Search\SearchApiQuery;
use Chill\MainBundle\Search\SearchApiInterface;
use Symfony\Component\Security\Core\Security;
use function array_map;
use function in_array;
class SearchPersonApiProvider implements SearchApiInterface
{
private PersonRepository $personRepository;
private Security $security;
private AuthorizationHelperInterface $authorizationHelper;
private ExtractDateFromPattern $extractDateFromPattern;
private PersonACLAwareRepositoryInterface $personACLAwareRepository;
private ExtractPhonenumberFromPattern $extractPhonenumberFromPattern;
private PersonACLAwareRepositoryInterface $personACLAwareRepository;
private PersonRepository $personRepository;
private Security $security;
public function __construct(
PersonRepository $personRepository,
PersonACLAwareRepositoryInterface $personACLAwareRepository,
@@ -36,6 +50,18 @@ class SearchPersonApiProvider implements SearchApiInterface
$this->extractPhonenumberFromPattern = $extractPhonenumberFromPattern;
}
public function getResult(string $key, array $metadata, float $pertinence)
{
return $this->personRepository->find($metadata['id']);
}
public function prepare(array $metadatas): void
{
$ids = array_map(fn ($m) => $m['id'], $metadatas);
$this->personRepository->findByIds($ids);
}
public function provideQuery(string $pattern, array $parameters): SearchApiQuery
{
$datesResult = $this->extractDateFromPattern->extractDates($pattern);
@@ -43,40 +69,27 @@ class SearchPersonApiProvider implements SearchApiInterface
$filtered = $phoneResult->getFilteredSubject();
return $this->personACLAwareRepository->buildAuthorizedQuery(
$filtered,
null,
null,
count($datesResult->getFound()) > 0 ? $datesResult->getFound()[0] : null,
null,
null,
null,
null,
count($phoneResult->getFound()) > 0 ? $phoneResult->getFound()[0] : null
)
->setSelectKey("person")
$filtered,
null,
null,
count($datesResult->getFound()) > 0 ? $datesResult->getFound()[0] : null,
null,
null,
null,
null,
count($phoneResult->getFound()) > 0 ? $phoneResult->getFound()[0] : null
)
->setSelectKey('person')
->setSelectJsonbMetadata("jsonb_build_object('id', person.id)");
}
public function supportsTypes(string $pattern, array $types, array $parameters): bool
{
return \in_array('person', $types);
}
public function prepare(array $metadatas): void
{
$ids = \array_map(fn($m) => $m['id'], $metadatas);
$this->personRepository->findByIds($ids);
}
public function supportsResult(string $key, array $metadatas): bool
{
return $key === 'person';
return 'person' === $key;
}
public function getResult(string $key, array $metadata, float $pertinence)
public function supportsTypes(string $pattern, array $types, array $parameters): bool
{
return $this->personRepository->find($metadata['id']);
return in_array('person', $types);
}
}