mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'refactor-using-rector-202303' into rector/rules-up-to-php74
This commit is contained in:
commit
80647147ee
@ -90,9 +90,7 @@ class CountPerson implements ExportInterface
|
|||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||||
{
|
{
|
||||||
// we gather all center the user choose.
|
// we gather all center the user choose.
|
||||||
$centers = array_map(static function ($el) {
|
$centers = array_map(static fn($el) => $el['center'], $acl);
|
||||||
return $el['center'];
|
|
||||||
}, $acl);
|
|
||||||
|
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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\MainBundle\Form;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Search\SearchProvider;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
||||||
|
|
||||||
class AdvancedSearchType extends AbstractType
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var SearchProvider
|
|
||||||
*/
|
|
||||||
protected $searchProvider;
|
|
||||||
|
|
||||||
public function __construct(SearchProvider $searchProvider)
|
|
||||||
{
|
|
||||||
$this->searchProvider = $searchProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
||||||
{
|
|
||||||
$this->searchProvider
|
|
||||||
->getHasAdvancedFormByName($options['search_service'])
|
|
||||||
->createSearchForm($builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
|
||||||
$resolver
|
|
||||||
->setRequired('search_service')
|
|
||||||
->setAllowedTypes('search_service', ['string']);
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,4 +20,6 @@ interface HasAdvancedSearchFormInterface extends SearchInterface
|
|||||||
public function convertFormDataToQuery(array $data);
|
public function convertFormDataToQuery(array $data);
|
||||||
|
|
||||||
public function convertTermsToFormData(array $terms);
|
public function convertTermsToFormData(array $terms);
|
||||||
|
|
||||||
|
public function getAdvancedSearchTitle(): string;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ use function count;
|
|||||||
class SearchProvider
|
class SearchProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var HasAdvancedSearchForm[]
|
* @var HasAdvancedSearchFormInterface[]
|
||||||
*/
|
*/
|
||||||
private $hasAdvancedFormSearchServices = [];
|
private $hasAdvancedFormSearchServices = [];
|
||||||
|
|
||||||
@ -99,13 +99,9 @@ class SearchProvider
|
|||||||
* return searchservice with an advanced form, defined in service
|
* return searchservice with an advanced form, defined in service
|
||||||
* definition.
|
* definition.
|
||||||
*
|
*
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @throws UnknowSearchNameException
|
* @throws UnknowSearchNameException
|
||||||
*
|
|
||||||
* @return HasAdvancedSearchForm
|
|
||||||
*/
|
*/
|
||||||
public function getHasAdvancedFormByName($name)
|
public function getHasAdvancedFormByName(string $name): HasAdvancedSearchFormInterface
|
||||||
{
|
{
|
||||||
if (array_key_exists($name, $this->hasAdvancedFormSearchServices)) {
|
if (array_key_exists($name, $this->hasAdvancedFormSearchServices)) {
|
||||||
return $this->hasAdvancedFormSearchServices[$name];
|
return $this->hasAdvancedFormSearchServices[$name];
|
||||||
@ -117,7 +113,9 @@ class SearchProvider
|
|||||||
public function getHasAdvancedFormSearchServices()
|
public function getHasAdvancedFormSearchServices()
|
||||||
{
|
{
|
||||||
//sort the array
|
//sort the array
|
||||||
uasort($this->hasAdvancedFormSearchServices, static fn(SearchInterface $a, SearchInterface $b) => $a->getOrder() <=> $b->getOrder());
|
uasort($this->hasAdvancedFormSearchServices, static function (HasAdvancedSearchFormInterface $a, HasAdvancedSearchFormInterface $b): int {
|
||||||
|
return $a->getOrder() <=> $b->getOrder();
|
||||||
|
});
|
||||||
|
|
||||||
return $this->hasAdvancedFormSearchServices;
|
return $this->hasAdvancedFormSearchServices;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdvancedSearchTitle()
|
public function getAdvancedSearchTitle(): string
|
||||||
{
|
{
|
||||||
return 'Search within persons';
|
return 'Search within persons';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user