class EmojiType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$countriesCode = Countries::getNames($options['choice_translation_locale']);
+ // If the option "only_emoji" is true, we display just the emoji
+ if (true === $options['only_emoji']) {
+ foreach ($countriesCode as $countryCode => $displayed) {
+ $choices[$countryCode] = self::getEmojiFlag($countryCode);
+ }
+ } else {
+ // else we display the emoji and the country name
foreach ($countriesCode as $countryCode => $displayed) {
$choices[$countryCode] = self::getEmojiFlag($countryCode).' '.$displayed;
}
}
return array_flip($choices);
});
},
'choice_translation_locale' => null,
+ // define the option and set "false" by default
+ 'only_emoji' => false
]);
$resolver->setAllowedTypes('choice_translation_locale', ['null', 'string']);
+ // the option should be a boolean
+ $resolver->setAllowedTypes('only_emoji', ['boolean']);
}
}
Last active
January 29, 2022 23:45
-
-
Save ismail1432/a8e8987b247f3c82d56d17a91f07725f to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment