Skip to content

Add add getChoiceLabel in AbstractTranslatedEnum #37

@nicolas-bastien

Description

@nicolas-bastien

Hi Yann,

In my project we need to get the translated choice in a list.

So in every actions, my new dev initialize an array with AbstractTranslatedEnum::getChoices and check if the value is set before displaying it.

Can we :

  • make an internal variable in AbstractTranslatedEnum to store the result so we do'nt have to walk through the array map each time the method is called
  • and a getChoice method like
public function getTranlatedChoice($value): string
{
    if(!this->hasChoice($value)) {
        return '';
     }

    return $this->getChoices()[$value];
}

I have Louis who will be more than happy to make it's first PR on a open source project.

What do you think about it ?

Nico

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions