diff --git a/DependencyInjection/ChillMainExtension.php b/DependencyInjection/ChillMainExtension.php index a6fbe4769..0e4c9f5dd 100644 --- a/DependencyInjection/ChillMainExtension.php +++ b/DependencyInjection/ChillMainExtension.php @@ -23,8 +23,11 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $container->setParameter('cl_chill_main.installation_name', - $config['installation_name']); + $container->setParameter('chill_main.installation_name', + $config['installation_name']); + + $container->setParameter('chill_main.available_languages', + $config['available_languages']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index c0af5d67e..168271f0d 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -21,12 +21,15 @@ class Configuration implements ConfigurationInterface $rootNode = $treeBuilder->root('cl_chill_main'); $rootNode - ->children() - ->scalarNode('installation_name') - ->cannotBeEmpty() - ->defaultValue('Chill') - ->end() - ->end(); + ->children() + ->scalarNode('installation_name') + ->cannotBeEmpty() + ->defaultValue('Chill') + ->end() + ->arrayNode('available_languages') + ->prototype('scalar')->end() + ->end() + ->end(); return $treeBuilder; } diff --git a/Form/Type/TranslatableStringFormType.php b/Form/Type/TranslatableStringFormType.php new file mode 100644 index 000000000..24f38d8d2 --- /dev/null +++ b/Form/Type/TranslatableStringFormType.php @@ -0,0 +1,33 @@ +availableLanguages = $availableLanguages; + $this->frameworkTranslatorFallback = $frameworkTranslatorFallback; + } + + public function buildForm(FormBuilderInterface $builder, array $options) { + foreach ($this->availableLanguages as $lang) { + $builder->add($lang, 'text', + array('required' => ($lang === $this->frameworkTranslatorFallback))); + } + } + + public function getName() + { + return 'translatable_string'; + } +} \ No newline at end of file diff --git a/Resources/config/services.yml b/Resources/config/services.yml index dadf583fa..751bf577c 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -7,7 +7,7 @@ services: #must be set in function to avoid circular reference with chill.main.twig.chill_menu calls: - [setContainer, ["@service_container"]] - + chill.main.twig.chill_menu: class: Chill\MainBundle\Routing\MenuTwig arguments: @@ -16,3 +16,12 @@ services: - [setContainer, ["@service_container"]] tags: - { name: twig.extension } + + chill.main.form.type.translatable.string: + class: Chill\MainBundle\Form\Type\TranslatableStringFormType + arguments: + - "%chill_main.available_languages%" + #- "%framework.translator.fallback%" + - "%locale%" + tags: + - { name: form.type, alias: translatable_string }