DX: do not loop on possible choices to display action

This commit is contained in:
Julien Fastré 2022-10-06 23:24:38 +02:00
parent f5997e39cd
commit ca67170ad3

View File

@ -74,15 +74,13 @@ class EmergencyFilter implements FilterInterface
public function describeAction($data, $format = 'string'): array public function describeAction($data, $format = 'string'): array
{ {
foreach (self::CHOICES as $k => $v) { return [
if ($v === $data['accepted_emergency']) { 'Filtered by emergency: only %emergency%', [
$choice = $k; '%emergency%' => $this->translator->trans(
} $data['accepted_emergency'] ? 'is emergency' : 'is not emergency'
} ),
],
return ['Filtered activity by emergency: only %emergency%', [ ];
'%emergency%' => $this->translator->trans($choice),
]];
} }
public function getTitle(): string public function getTitle(): string