[WIP] get default data from saved exports for center and export steps

This commit is contained in:
Julien Fastré 2023-06-02 15:32:38 +02:00
parent d1e1b1c4ce
commit fb0afc7e0a
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
9 changed files with 225 additions and 97 deletions

View File

@ -13,13 +13,16 @@ namespace Chill\MainBundle\Controller;
use Chill\MainBundle\Entity\SavedExport;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Export\DirectExportInterface;
use Chill\MainBundle\Export\ExportFormHelper;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\ExportManager;
use Chill\MainBundle\Form\SavedExportType;
use Chill\MainBundle\Form\Type\Export\ExportType;
use Chill\MainBundle\Form\Type\Export\FormatterType;
use Chill\MainBundle\Form\Type\Export\PickCenterType;
use Chill\MainBundle\Redis\ChillRedis;
use Chill\MainBundle\Repository\SavedExportRepositoryInterface;
use Chill\MainBundle\Security\Authorization\SavedExportVoter;
use Doctrine\ORM\EntityManagerInterface;
use LogicException;
@ -37,6 +40,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
use function serialize;
@ -89,6 +93,8 @@ class ExportController extends AbstractController
TranslatorInterface $translator,
EntityManagerInterface $entityManager,
private readonly ExportFormHelper $exportFormHelper,
private readonly SavedExportRepositoryInterface $savedExportRepository,
private readonly Security $security,
) {
$this->entityManager = $entityManager;
$this->redis = $chillRedis;
@ -103,12 +109,11 @@ class ExportController extends AbstractController
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
$export = $exportManager->getExport($alias);
$key = $request->query->get('key', null);
$savedExport = $this->getSavedExportFromRequest($request);
[$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key);
[$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key, $savedExport);
$formatterAlias = $exportManager->getFormatterAlias($dataExport['export']);
@ -146,8 +151,9 @@ class ExportController extends AbstractController
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
$key = $request->query->get('key', null);
$savedExport = $this->getSavedExportFromRequest($request);
[$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key);
[$dataCenters, $dataExport, $dataFormatter] = $this->rebuildData($key, $savedExport);
return $exportManager->generate(
$alias,
@ -206,12 +212,8 @@ class ExportController extends AbstractController
* 3. 'generate': gather data from session from the previous steps, and
* make a redirection to the "generate" action with data in query (HTTP GET)
*
* @param string $request
* @param Request $alias
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function newAction(Request $request, $alias)
public function newAction(Request $request, string $alias): Response
{
// first check for ACL
$exportManager = $this->exportManager;
@ -221,20 +223,22 @@ class ExportController extends AbstractController
throw $this->createAccessDeniedException('The user does not have access to this export');
}
$savedExport = $this->getSavedExportFromRequest($request);
$step = $request->query->getAlpha('step', 'centers');
switch ($step) {
case 'centers':
return $this->selectCentersStep($request, $export, $alias);
return $this->selectCentersStep($request, $export, $alias, $savedExport);
case 'export':
return $this->exportFormStep($request, $export, $alias);
return $this->exportFormStep($request, $export, $alias, $savedExport);
case 'formatter':
return $this->formatterFormStep($request, $export, $alias);
return $this->formatterFormStep($request, $export, $alias, $savedExport);
case 'generate':
return $this->forwardToGenerate($request, $export, $alias);
return $this->forwardToGenerate($request, $export, $alias, $savedExport);
default:
throw $this->createNotFoundException("The given step '{$step}' is invalid");
@ -284,29 +288,35 @@ class ExportController extends AbstractController
/**
* create a form to show on different steps.
*
* @param string $alias
* @param array $data the data from previous step. Required for steps 'formatter' and 'generate_formatter'
* @param mixed $step
*/
protected function createCreateFormExport($alias, $step, $data = []): FormInterface
protected function createCreateFormExport(string $alias, string $step, array $data, ?SavedExport $savedExport): FormInterface
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
$isGenerate = strpos($step, 'generate_') === 0;
$options = match ($step) {
'export', 'generate_export' => ['picked_centers' => $exportManager->getPickedCenters($data['centers'])],
default => [],
};
$defaultFormData = match ($savedExport) {
null => $this->exportFormHelper->getDefaultData($step, $exportManager->getExport($alias), $options),
default => $this->exportFormHelper->savedExportDataToFormData($savedExport, $step, $options),
};
$builder = $this->formFactory
->createNamedBuilder(
null,
FormType::class,
$this->exportFormHelper->getDefaultData($step, $exportManager->getExport($alias)),
$defaultFormData,
[
'method' => $isGenerate ? 'GET' : 'POST',
'csrf_protection' => $isGenerate ? false : true,
'csrf_protection' => !$isGenerate,
]
);
// TODO: add a condition to be able to select a regroupment of centers?
if ('centers' === $step || 'generate_centers' === $step) {
$builder->add('centers', PickCenterType::class, [
'export_alias' => $alias,
@ -342,13 +352,8 @@ class ExportController extends AbstractController
*
* When the method is POST, the form is stored if valid, and a redirection
* is done to next step.
*
* @param string $alias
* @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export
*
* @return \Symfony\Component\HttpFoundation\Response
*/
private function exportFormStep(Request $request, $export, $alias)
private function exportFormStep(Request $request, DirectExportInterface|ExportInterface $export, string $alias, ?SavedExport $savedExport = null): Response
{
$exportManager = $this->exportManager;
@ -364,7 +369,7 @@ class ExportController extends AbstractController
$export = $exportManager->getExport($alias);
$form = $this->createCreateFormExport($alias, 'export', $data);
$form = $this->createCreateFormExport($alias, 'export', $data, $savedExport);
if ($request->getMethod() === 'POST') {
$form->handleRequest($request);
@ -386,6 +391,7 @@ class ExportController extends AbstractController
$this->generateUrl('chill_main_export_new', [
'step' => $this->getNextStep('export', $export),
'alias' => $alias,
'from_saved' => $request->get('from_saved', '')
])
);
}
@ -406,13 +412,8 @@ class ExportController extends AbstractController
*
* If the form is posted and valid, store the data in session and
* redirect to the next step.
*
* @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export
* @param string $alias
*
* @return \Symfony\Component\HttpFoundation\Response
*/
private function formatterFormStep(Request $request, $export, $alias)
private function formatterFormStep(Request $request, DirectExportInterface|ExportInterface $export, string $alias, ?SavedExport $savedExport = null): Response
{
// check we have data from the previous step (export step)
$data = $this->session->get('export_step', null);
@ -424,7 +425,7 @@ class ExportController extends AbstractController
]);
}
$form = $this->createCreateFormExport($alias, 'formatter', $data);
$form = $this->createCreateFormExport($alias, 'formatter', $data, $savedExport);
if ($request->getMethod() === 'POST') {
$form->handleRequest($request);
@ -443,6 +444,7 @@ class ExportController extends AbstractController
[
'alias' => $alias,
'step' => $this->getNextStep('formatter', $export),
'from_saved' => $request->get('from_saved', ''),
]
));
}
@ -469,7 +471,7 @@ class ExportController extends AbstractController
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
private function forwardToGenerate(Request $request, $export, $alias)
private function forwardToGenerate(Request $request, $export, $alias, ?SavedExport $savedExport)
{
$dataCenters = $this->session->get('centers_step_raw', null);
$dataFormatter = $this->session->get('formatter_step_raw', null);
@ -501,17 +503,17 @@ class ExportController extends AbstractController
return $this->redirectToRoute('chill_main_export_download', ['key' => $key, 'alias' => $alias]);
}
private function rebuildData($key)
private function rebuildData($key, ?SavedExport $savedExport)
{
$rawData = $this->rebuildRawData($key);
$alias = $rawData['alias'];
$formCenters = $this->createCreateFormExport($alias, 'generate_centers');
$formCenters = $this->createCreateFormExport($alias, 'generate_centers', [], $savedExport);
$formCenters->submit($rawData['centers']);
$dataCenters = $formCenters->getData();
$formExport = $this->createCreateFormExport($alias, 'generate_export', $dataCenters);
$formExport = $this->createCreateFormExport($alias, 'generate_export', $dataCenters, $savedExport);
$formExport->submit($rawData['export']);
$dataExport = $formExport->getData();
@ -519,7 +521,8 @@ class ExportController extends AbstractController
$formFormatter = $this->createCreateFormExport(
$alias,
'generate_formatter',
$dataExport
$dataExport,
$savedExport
);
$formFormatter->submit($rawData['formatter']);
$dataFormatter = $formFormatter->getData();
@ -534,12 +537,12 @@ class ExportController extends AbstractController
*
* @return Response
*/
private function selectCentersStep(Request $request, $export, $alias)
private function selectCentersStep(Request $request, $export, $alias, ?SavedExport $savedExport = null)
{
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager;
$form = $this->createCreateFormExport($alias, 'centers');
$form = $this->createCreateFormExport($alias, 'centers', [], $savedExport);
if ($request->getMethod() === 'POST') {
$form->handleRequest($request);
@ -571,6 +574,7 @@ class ExportController extends AbstractController
return $this->redirectToRoute('chill_main_export_new', [
'step' => $this->getNextStep('centers', $export),
'alias' => $alias,
'from_saved' => $request->get('from_saved', ''),
]);
}
}
@ -677,4 +681,18 @@ class ExportController extends AbstractController
return $rawData;
}
private function getSavedExportFromRequest(Request $request): ?SavedExport
{
$savedExport = match ($savedExportId = $request->query->get('from_saved', '')) {
'' => null,
default => $this->savedExportRepository->find($savedExportId),
};
if (null !== $savedExport && !$this->security->isGranted(SavedExportVoter::EDIT, $savedExport)) {
throw new AccessDeniedHttpException("saved export edition not allowed");
}
return $savedExport;
}
}

View File

@ -11,27 +11,127 @@ declare(strict_types=1);
namespace Chill\MainBundle\Export;
use Chill\MainBundle\Entity\SavedExport;
use Chill\MainBundle\Form\Type\Export\ExportType;
use Chill\MainBundle\Form\Type\Export\FilterType;
use Chill\MainBundle\Form\Type\Export\PickCenterType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormFactoryInterface;
final readonly class ExportFormHelper
{
public function __construct(
private ExportManager $exportManager,
private AuthorizationHelperForCurrentUserInterface $authorizationHelper,
private ExportManager $exportManager,
private FormFactoryInterface $formFactory,
) {
}
/**
* @param list<"centers"> $steps
*/
public function getDefaultData(string $step, ExportInterface $export): array
public function getDefaultData(string $step, ExportInterface|DirectExportInterface $export, array $options = []): array
{
$data = [];
return match ($step) {
'centers', 'generate_centers' => ['centers' => $this->authorizationHelper->getReachableCenters($export->requiredRole())],
'export', 'generate_export' => ['export' => $this->getDefaultDataStepExport($export, $options)],
'formatter', 'generate_formatter' => [],
default => throw new \LogicException("step not allowed : " . $step),
};
}
if ($step === 'centers') {
$data['centers'] = $this->authorizationHelper->getReachableCenters($export->requiredRole());
private function getDefaultDataStepExport(ExportInterface|DirectExportInterface $export, array $options): array
{
$data = [
ExportType::EXPORT_KEY => $export->getFormDefaultData(),
ExportType::FILTER_KEY => [],
ExportType::AGGREGATOR_KEY => [],
ExportType::PICK_FORMATTER_KEY => [],
];
$filters = $this->exportManager->getFiltersApplyingOn($export, $options['picked_centers']);
foreach ($filters as $alias => $filter) {
$data[ExportType::FILTER_KEY][$alias] = [
FilterType::ENABLED_FIELD => false,
'form' => $filter->getFormDefaultData()
];
}
$aggregators = $this->exportManager
->getAggregatorsApplyingOn($export, $options['picked_centers']);
foreach ($aggregators as $alias => $aggregator) {
$data[ExportType::AGGREGATOR_KEY][$alias] = [
'enabled' => false,
'form' => $aggregator->getFormDefaultData(),
];
}
$allowedFormatters = $this->exportManager
->getFormattersByTypes($export->getAllowedFormattersTypes());
$choices = [];
foreach (array_keys(iterator_to_array($allowedFormatters)) as $alias) {
$choices[] = $alias;
}
$data[ExportType::PICK_FORMATTER_KEY]['alias'] = match (count($choices)) {
1 => $choices[0],
default => null,
};
return $data;
}
public function savedExportDataToFormData(
SavedExport $savedExport,
string $step,
array $formOptions = [],
): array {
return match ($step) {
'centers', 'generate_centers' => $this->savedExportDataToFormDataStepCenter($savedExport),
'export', 'generate_export' => $this->savedExportDataToFormDataStepExport($savedExport, $formOptions),
'formatter', 'generate_formatter' => [],
default => throw new \LogicException("this step is not allowed: " . $step),
};
}
private function savedExportDataToFormDataStepCenter(
SavedExport $savedExport,
): array {
$builder = $this->formFactory
->createBuilder(
FormType::class,
[],
[
'csrf_protection' => false,
]
);
$builder->add('centers', PickCenterType::class, [
'export_alias' => $savedExport->getExportAlias(),
]);
$form = $builder->getForm();
$form->submit($savedExport->getOptions()['centers']);
return $form->getData();
}
private function savedExportDataToFormDataStepExport(
SavedExport $savedExport,
array $formOptions
): array {
$builder = $this->formFactory
->createBuilder(
FormType::class,
[],
[
'csrf_protection' => false,
]
);
$builder->add('export', ExportType::class, [
'export_alias' => $savedExport->getExportAlias(), ...$formOptions
]);
$form = $builder->getForm();
$form->submit($savedExport->getOptions()['export']);
return $form->getData();
}
}

View File

@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\MainBundle\Export;
use Chill\MainBundle\Form\Type\Export\ExportType;
use Chill\MainBundle\Form\Type\Export\PickCenterType;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Doctrine\ORM\QueryBuilder;
use Generator;
@ -131,9 +130,9 @@ class ExportManager
*
* @internal This class check the interface implemented by export, and, if ´ListInterface´ is used, return an empty array
*
* @return AggregatorInterface[] a \Generator that contains aggretagors. The key is the filter's alias
* @return null|iterable<string, AggregatorInterface> a \Generator that contains aggretagors. The key is the filter's alias
*/
public function &getAggregatorsApplyingOn(ExportInterface $export, ?array $centers = null)
public function &getAggregatorsApplyingOn(ExportInterface $export, ?array $centers = null): ?iterable
{
if ($export instanceof ListInterface) {
return;
@ -149,7 +148,7 @@ class ExportManager
}
}
public function addExportElementsProvider(ExportElementsProviderInterface $provider, $prefix)
public function addExportElementsProvider(ExportElementsProviderInterface $provider, string $prefix): void
{
foreach ($provider->getExportElements() as $suffix => $element) {
$alias = $prefix . '_' . $suffix;
@ -173,23 +172,16 @@ class ExportManager
* add a formatter.
*
* @internal used by DI
*
* @param string $alias
*/
public function addFormatter(FormatterInterface $formatter, $alias)
public function addFormatter(FormatterInterface $formatter, string $alias)
{
$this->formatters[$alias] = $formatter;
}
/**
* Generate a response which contains the requested data.
*
* @param string $exportAlias
* @param mixed[] $data
*
* @return Response
*/
public function generate($exportAlias, array $pickedCentersData, array $data, array $formatterData)
public function generate(string $exportAlias, array $pickedCentersData, array $data, array $formatterData): Response
{
$export = $this->getExport($exportAlias);
$centers = $this->getPickedCenters($pickedCentersData);
@ -288,7 +280,11 @@ class ExportManager
return $this->aggregators[$alias];
}
public function getAggregators(array $aliases)
/**
* @param array $aliases
* @return iterable<string, AggregatorInterface>
*/
public function getAggregators(array $aliases): iterable
{
foreach ($aliases as $alias) {
yield $alias => $this->getAggregator($alias);
@ -296,9 +292,11 @@ class ExportManager
}
/**
* @return string[] the existing type for known exports
* Get the types for known exports
*
* @return list<string> the existing type for known exports
*/
public function getExistingExportsTypes()
public function getExistingExportsTypes(): array
{
$existingTypes = [];
@ -317,10 +315,8 @@ class ExportManager
* @param string $alias
*
* @throws RuntimeException
*
* @return ExportInterface
*/
public function getExport($alias)
public function getExport($alias): ExportInterface|DirectExportInterface
{
if (!array_key_exists($alias, $this->exports)) {
throw new RuntimeException("The export with alias {$alias} is not known.");
@ -334,9 +330,9 @@ class ExportManager
*
* @param bool $whereUserIsGranted if true (default), restrict to user which are granted the right to execute the export
*
* @return ExportInterface[] an array where export's alias are keys
* @return iterable<string, ExportInterface|DirectExportInterface> an array where export's alias are keys
*/
public function getExports($whereUserIsGranted = true)
public function getExports($whereUserIsGranted = true): iterable
{
foreach ($this->exports as $alias => $export) {
if ($whereUserIsGranted) {
@ -354,9 +350,9 @@ class ExportManager
*
* @param bool $whereUserIsGranted
*
* @return array where keys are the groups's name and value is an array of exports
* @return array<string, array<string, ExportInterface|DirectExportInterface>> where keys are the groups's name and value is an array of exports
*/
public function getExportsGrouped($whereUserIsGranted = true): array
public function getExportsGrouped(bool $whereUserIsGranted = true): array
{
$groups = ['_' => []];
@ -375,10 +371,8 @@ class ExportManager
* @param string $alias
*
* @throws RuntimeException if the filter is not known
*
* @return FilterInterface
*/
public function getFilter($alias)
public function getFilter(string $alias): FilterInterface
{
if (!array_key_exists($alias, $this->filters)) {
throw new RuntimeException("The filter with alias {$alias} is not known.");
@ -390,16 +384,17 @@ class ExportManager
/**
* get all filters.
*
* @param Generator $aliases
* @param array<string> $aliases
* @return iterable<string, FilterInterface> $aliases
*/
public function getFilters(array $aliases)
public function getFilters(array $aliases): iterable
{
foreach ($aliases as $alias) {
yield $alias => $this->getFilter($alias);
}
}
public function getFormatter($alias)
public function getFormatter(string $alias): FormatterInterface
{
if (!array_key_exists($alias, $this->formatters)) {
throw new RuntimeException("The formatter with alias {$alias} is not known.");
@ -414,7 +409,7 @@ class ExportManager
* @param array $data the data from the export form
* @string the formatter alias|null
*/
public function getFormatterAlias(array $data)
public function getFormatterAlias(array $data): ?string
{
if (array_key_exists(ExportType::PICK_FORMATTER_KEY, $data)) {
return $data[ExportType::PICK_FORMATTER_KEY]['alias'];
@ -426,9 +421,9 @@ class ExportManager
/**
* Get all formatters which supports one of the given types.
*
* @return Generator
* @return iterable<string, FormatterInterface>
*/
public function getFormattersByTypes(array $types)
public function getFormattersByTypes(array $types): iterable
{
foreach ($this->formatters as $alias => $formatter) {
if (in_array($formatter->getType(), $types, true)) {
@ -445,7 +440,7 @@ class ExportManager
*
* @return \Chill\MainBundle\Entity\Center[] the picked center
*/
public function getPickedCenters(array $data)
public function getPickedCenters(array $data): array
{
return $data;
}
@ -455,9 +450,9 @@ class ExportManager
*
* @param array $data the data from the export form
*
* @return string[]
* @return list<string>
*/
public function getUsedAggregatorsAliases(array $data)
public function getUsedAggregatorsAliases(array $data): array
{
$aggregators = $this->retrieveUsedAggregators($data[ExportType::AGGREGATOR_KEY]);
@ -471,9 +466,8 @@ class ExportManager
* @param \Chill\MainBundle\Export\ExportElementInterface $element
* @param DirectExportInterface|ExportInterface $export
*
* @return bool
*/
public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null)
public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null): bool
{
if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) {
$role = $element->requiredRole();
@ -548,13 +542,12 @@ class ExportManager
* Check for acl. If an user is not authorized to see an aggregator, throw an
* UnauthorizedException.
*
* @param type $data
* @throw UnauthorizedHttpException if the user is not authorized
*/
private function handleAggregators(
ExportInterface $export,
QueryBuilder $qb,
$data,
array $data,
array $center
) {
$aggregators = $this->retrieveUsedAggregators($data);
@ -600,9 +593,9 @@ class ExportManager
/**
* @param mixed $data
*
* @return AggregatorInterface[]
* @return iterable<string, AggregatorInterface>
*/
private function retrieveUsedAggregators($data)
private function retrieveUsedAggregators($data): iterable
{
if (null === $data) {
return [];

View File

@ -32,7 +32,6 @@ class AggregatorType extends AbstractType
->add('enabled', CheckboxType::class, [
'value' => true,
'required' => false,
'data' => false,
]);
$filterFormBuilder = $builder->create('form', FormType::class, [

View File

@ -33,7 +33,6 @@ class FilterType extends AbstractType
$builder
->add(self::ENABLED_FIELD, CheckboxType::class, [
'value' => true,
'data' => false,
'required' => false,
]);

View File

@ -47,8 +47,6 @@ class PickFormatterType extends AbstractType
'multiple' => false,
'placeholder' => 'Choose a format',
]);
//$builder->get('type')->addModelTransformer($transformer);
}
public function configureOptions(OptionsResolver $resolver)

View File

@ -48,6 +48,7 @@ final class MaritalStatusAggregator implements AggregatorInterface
public function applyOn()
{
return 'abcde';
return Declarations::PERSON_TYPE;
}
@ -56,6 +57,11 @@ final class MaritalStatusAggregator implements AggregatorInterface
// no form
}
public function getFormDefaultData(): array
{
return [];
}
public function getLabels($key, array $values, $data)
{
return function ($value): string {

View File

@ -38,6 +38,11 @@ class CountPerson implements ExportInterface, GroupedExportInterface
// No form necessary
}
public function getFormDefaultData(): array
{
return [];
}
public function getAllowedFormattersTypes()
{
return [FormatterInterface::TYPE_TABULAR];
@ -115,9 +120,9 @@ class CountPerson implements ExportInterface, GroupedExportInterface
public function supportsModifiers()
{
return [
Declarations::PERSON_TYPE,
Declarations::PERSON_IMPLIED_IN,
//Declarations::ACP_TYPE
'abcde',
//Declarations::PERSON_TYPE,
//Declarations::PERSON_IMPLIED_IN,
];
}
}

View File

@ -73,6 +73,7 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface
public function applyOn()
{
return 'abcde';
return Declarations::PERSON_TYPE;
}
@ -92,6 +93,15 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface
]);
}
public function getFormDefaultData(): array
{
return [
'min_age' => 0,
'max_age' => 120,
'date_calc' => new RollingDate(RollingDate::T_TODAY),
];
}
public function describeAction($data, $format = 'string')
{
return ['Filtered by person\'s age: '