From de5226d84b6b2c64bb51fb7b35b8d292d5a01cff Mon Sep 17 00:00:00 2001 From: Bozhidar Hristov Date: Tue, 1 Aug 2017 15:29:18 +0300 Subject: [PATCH] Fix Templating in Symfony ~2.6 --- src/Form/Type/TranslatedEntityType.php | 9 +++++++-- src/Form/Type/TranslationsFieldsType.php | 5 ++++- src/Form/Type/TranslationsFormsType.php | 4 ++++ src/Form/Type/TranslationsLocalesSelectorType.php | 6 +++++- src/Form/Type/TranslationsType.php | 4 ++++ src/TranslationService.php | 4 ++-- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Form/Type/TranslatedEntityType.php b/src/Form/Type/TranslatedEntityType.php index 3dc27f5..2b6c716 100644 --- a/src/Form/Type/TranslatedEntityType.php +++ b/src/Form/Type/TranslatedEntityType.php @@ -2,11 +2,11 @@ namespace ObjectBG\TranslationBundle\Form\Type; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; /** * Translated entity @@ -40,7 +40,8 @@ public function configureOptions(OptionsResolver $resolver) throw new \Exception('Error while getting request'); } - return $options['translation_path'] . '[' . $this->request->getLocale() . '].' . $options['translation_property']; + return $options['translation_path'].'['.$this->request->getLocale( + ).'].'.$options['translation_property']; }, ) ); @@ -51,4 +52,8 @@ public function getParent() return EntityType::class; } + public function getBlockPrefix() + { + return 'object_bg_translated_entity'; + } } diff --git a/src/Form/Type/TranslationsFieldsType.php b/src/Form/Type/TranslationsFieldsType.php index b8c2880..fc8adb3 100644 --- a/src/Form/Type/TranslationsFieldsType.php +++ b/src/Form/Type/TranslationsFieldsType.php @@ -37,5 +37,8 @@ public function configureOptions(OptionsResolver $resolver) ); } - + public function getBlockPrefix() + { + return 'object_bg_translation_fields'; + } } diff --git a/src/Form/Type/TranslationsFormsType.php b/src/Form/Type/TranslationsFormsType.php index 10dbe40..9e041d0 100644 --- a/src/Form/Type/TranslationsFormsType.php +++ b/src/Form/Type/TranslationsFormsType.php @@ -95,4 +95,8 @@ public function configureOptions(OptionsResolver $resolver) ); } + public function getBlockPrefix() + { + return 'object_bg_translations_forms'; + } } diff --git a/src/Form/Type/TranslationsLocalesSelectorType.php b/src/Form/Type/TranslationsLocalesSelectorType.php index 3f1120c..958cc22 100644 --- a/src/Form/Type/TranslationsLocalesSelectorType.php +++ b/src/Form/Type/TranslationsLocalesSelectorType.php @@ -44,7 +44,11 @@ public function configureOptions(OptionsResolver $resolver) public function getParent() { - return \Symfony\Component\Form\Extension\Core\Type\ChoiceType::class; + return \Symfony\Component\Form\Extension\Core\Type\ChoiceType::class; } + public function getBlockPrefix() + { + return 'object_bg_locales_selector'; + } } diff --git a/src/Form/Type/TranslationsType.php b/src/Form/Type/TranslationsType.php index 59ce85e..b658761 100644 --- a/src/Form/Type/TranslationsType.php +++ b/src/Form/Type/TranslationsType.php @@ -71,4 +71,8 @@ public function configureOptions(OptionsResolver $resolver) ); } + public function getBlockPrefix() + { + return 'object_bg_translations'; + } } diff --git a/src/TranslationService.php b/src/TranslationService.php index b549c2d..e5fe1c5 100644 --- a/src/TranslationService.php +++ b/src/TranslationService.php @@ -132,7 +132,7 @@ public function getLocales() { $locales = array(); foreach ($this->getLanguages() as $lang) { - $locales[$lang->getLocale()] = $lang->getName(); + $locales[$lang->getLocale()] = $lang->getName().'('.$lang->getLocale().')'; } return $locales; @@ -298,7 +298,7 @@ private function getFieldsList($options, $class) // Check existing foreach ($formFields as $field) { if (!property_exists($class, $field)) { - throw new \Exception("Field '" . $field . "' doesn't exist in " . $class); + throw new \Exception("Field '".$field."' doesn't exist in ".$class); } }