mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 18:13:48 +00:00
Upgrade php to v8.3 with rector
This commit is contained in:
@@ -21,6 +21,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface
|
||||
{
|
||||
// add specific role for this filter
|
||||
#[\Override]
|
||||
public function addRole(): ?string
|
||||
{
|
||||
// we do not need any new role for this filter, so we return null
|
||||
@@ -28,6 +29,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
|
||||
}
|
||||
|
||||
// here, we alter the query created by Export
|
||||
#[\Override]
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
@@ -52,12 +54,14 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
|
||||
}
|
||||
|
||||
// we give information on which type of export this filter applies
|
||||
#[\Override]
|
||||
public function applyOn()
|
||||
{
|
||||
return 'person';
|
||||
}
|
||||
|
||||
// we build a form to collect some parameters from the users
|
||||
#[\Override]
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_from', DateType::class, [
|
||||
@@ -74,6 +78,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
|
||||
'format' => 'dd-MM-yyyy',
|
||||
]);
|
||||
}
|
||||
#[\Override]
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['date_from' => new DateTime(), 'date_to' => new DateTime()];
|
||||
@@ -81,6 +86,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
|
||||
|
||||
// here, we create a simple string which will describe the action of
|
||||
// the filter in the Response
|
||||
#[\Override]
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return ['Filtered by person\'s birtdate: '
|
||||
@@ -90,6 +96,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
|
||||
], ];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Filter by person\'s birthdate';
|
||||
@@ -99,6 +106,7 @@ class BirthdateFilter implements ExportElementValidatedInterface, FilterInterfac
|
||||
// is executed here. This function is added by the interface
|
||||
// `ExportElementValidatedInterface`, and can be ignore if there is
|
||||
// no need for a validation
|
||||
#[\Override]
|
||||
public function validateForm($data, ExecutionContextInterface $context)
|
||||
{
|
||||
$date_from = $data['date_from'];
|
||||
|
@@ -32,25 +32,30 @@ class CountPerson implements ExportInterface
|
||||
$this->entityManager = $em;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// this export does not add any form
|
||||
}
|
||||
#[\Override]
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getAllowedFormattersTypes()
|
||||
{
|
||||
return [FormatterInterface::TYPE_TABULAR];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription()
|
||||
{
|
||||
return 'Count peoples by various parameters.';
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
// the Closure which will be executed by the formatter.
|
||||
@@ -60,6 +65,7 @@ class CountPerson implements ExportInterface
|
||||
};
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
// this array match the result keys in the query. We have only
|
||||
@@ -67,21 +73,25 @@ class CountPerson implements ExportInterface
|
||||
return ['export_result'];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getResult($query, $data)
|
||||
{
|
||||
return $query->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Count peoples';
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getType()
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
// we gather all center the user choose.
|
||||
@@ -98,11 +108,13 @@ class CountPerson implements ExportInterface
|
||||
return $qb;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function requiredRole(): string
|
||||
{
|
||||
return PersonVoter::STATS;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function supportsModifiers()
|
||||
{
|
||||
// explain the export manager which formatters and filters are allowed
|
||||
|
Reference in New Issue
Block a user