Skip to content

Commit

Permalink
Fix Templating in Symfony ~2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Bozhidar Hristov committed Aug 1, 2017
1 parent 4d14025 commit de5226d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/Form/Type/TranslatedEntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'];
},
)
);
Expand All @@ -51,4 +52,8 @@ public function getParent()
return EntityType::class;
}

public function getBlockPrefix()
{
return 'object_bg_translated_entity';
}
}
5 changes: 4 additions & 1 deletion src/Form/Type/TranslationsFieldsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ public function configureOptions(OptionsResolver $resolver)
);
}


public function getBlockPrefix()
{
return 'object_bg_translation_fields';
}
}
4 changes: 4 additions & 0 deletions src/Form/Type/TranslationsFormsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,8 @@ public function configureOptions(OptionsResolver $resolver)
);
}

public function getBlockPrefix()
{
return 'object_bg_translations_forms';
}
}
6 changes: 5 additions & 1 deletion src/Form/Type/TranslationsLocalesSelectorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
4 changes: 4 additions & 0 deletions src/Form/Type/TranslationsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ public function configureOptions(OptionsResolver $resolver)
);
}

public function getBlockPrefix()
{
return 'object_bg_translations';
}
}
4 changes: 2 additions & 2 deletions src/TranslationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit de5226d

Please sign in to comment.