user-profile - sidebar links and language settings (#369)

This commit is contained in:
Kevin Papst
2018-10-23 23:59:38 +02:00
committed by GitHub
parent 0165658659
commit 6633c550f5
28 changed files with 280 additions and 242 deletions

View File

@@ -19,16 +19,36 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class LanguageType extends AbstractType
{
/**
* @var string[]
*/
private $locales = [];
/**
* @param array|string $locales
*/
public function __construct($locales)
{
if (!is_array($locales)) {
$locales = explode('|', $locales);
}
$this->locales = $locales;
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$choices = [];
foreach ($this->locales as $key) {
$name = ucfirst(Intl::getLocaleBundle()->getLocaleName($key, $key));
$choices[$name] = $key;
}
$resolver->setDefaults([
'choices' => [
Intl::getLocaleBundle()->getLocaleName('de', 'de') => 'de',
Intl::getLocaleBundle()->getLocaleName('en', 'en') => 'en',
]
'choices' => $choices
]);
}