From 74d79e1ee0a75022a1e2bb2cac04756c848a9d8e Mon Sep 17 00:00:00 2001 From: Mathieu Ducrot Date: Tue, 4 Jun 2024 17:22:36 +0200 Subject: [PATCH] Add AbstractApiCallAdmin::getOriginChoices for api call origin filter --- src/Admin/Monitoring/AbstractApiCallAdmin.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Admin/Monitoring/AbstractApiCallAdmin.php b/src/Admin/Monitoring/AbstractApiCallAdmin.php index c263603..0c7d52b 100644 --- a/src/Admin/Monitoring/AbstractApiCallAdmin.php +++ b/src/Admin/Monitoring/AbstractApiCallAdmin.php @@ -37,9 +37,13 @@ protected function configureDefaultSortValues(array &$sortValues): void protected function configureDatagridFilters(DatagridMapper $filter): void { $filter - ->add('origin', null, [ + ->add('origin', ChoiceFilter::class, [ 'label' => 'label.origin', 'show_filter' => true, + 'field_type' => ChoiceType::class, + 'field_options' => [ + 'choices' => $this->getOriginChoices(), + ], ]) ->add('status', ChoiceFilter::class, [ 'label' => 'label.result', @@ -82,7 +86,10 @@ protected function configureListFields(ListMapper $list): void $list ->add('id', null, ['label' => 'field.label_id']) ->add('startedAt', null, ['label' => 'label.started_at']) - ->add('origin', null, ['label' => 'label.origin']) + ->add('origin', FieldDescriptionInterface::TYPE_CHOICE, [ + 'label' => 'label.origin', + 'choices' => array_flip($this->getOriginChoices()), + ]) ->add('statusCode', null, [ 'label' => 'label.result', 'template' => '@SmartSonata/admin/base_field/list_api_call_status_code.html.twig', @@ -107,7 +114,6 @@ protected function configureShowFields(ShowMapper $show): void ->add('type', FieldDescriptionInterface::TYPE_CHOICE, [ 'label' => 'label.route', 'choices' => array_flip($this->getRouteChoices()), - 'choice_translation_domain' => 'admin', ]) ->add('startedAt', null, ['label' => 'label.started_at']) ->add('endedAt', null, ['label' => 'label.ended_at']) @@ -119,7 +125,10 @@ protected function configureShowFields(ShowMapper $show): void ->add('summary', null, ['label' => 'label.summary']) ->end() ->with('api_params', ['label' => 'label.api_params', 'class' => 'col-md-8']) - ->add('origin', null, ['label' => 'label.origin']) + ->add('origin', FieldDescriptionInterface::TYPE_CHOICE, [ + 'label' => 'label.origin', + 'choices' => array_flip($this->getOriginChoices()), + ]) ->add('statusCode', null, [ 'label' => 'label.result', 'template' => '@SmartSonata/admin/base_field/show_api_call_status_code.html.twig', @@ -158,4 +167,6 @@ private function getStatusChoices(): array } abstract protected function getRouteChoices(): array; + + abstract protected function getOriginChoices(): array; }