Translator component has default domain for null implemented

no need to have default translation domain logic in 3 different places
This commit is contained in:
Tobias Schultze 2015-03-24 19:34:06 +01:00 committed by Fabien Potencier
parent d5673c2028
commit ccd32d5995
3 changed files with 2 additions and 14 deletions

View File

@ -90,19 +90,11 @@ class TranslationExtension extends \Twig_Extension
public function trans($message, array $arguments = array(), $domain = null, $locale = null) public function trans($message, array $arguments = array(), $domain = null, $locale = null)
{ {
if (null === $domain) {
$domain = 'messages';
}
return $this->translator->trans($message, $arguments, $domain, $locale); return $this->translator->trans($message, $arguments, $domain, $locale);
} }
public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null) public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null)
{ {
if (null === $domain) {
$domain = 'messages';
}
return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale); return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
} }

View File

@ -56,7 +56,7 @@ abstract class BaseType extends AbstractType
$uniqueBlockPrefix = '_'.$blockName; $uniqueBlockPrefix = '_'.$blockName;
} }
if (!$translationDomain) { if (null === $translationDomain) {
$translationDomain = $view->parent->vars['translation_domain']; $translationDomain = $view->parent->vars['translation_domain'];
} }
} else { } else {
@ -76,10 +76,6 @@ abstract class BaseType extends AbstractType
} }
$blockPrefixes[] = $uniqueBlockPrefix; $blockPrefixes[] = $uniqueBlockPrefix;
if (!$translationDomain) {
$translationDomain = 'messages';
}
$view->vars = array_replace($view->vars, array( $view->vars = array_replace($view->vars, array(
'form' => $view, 'form' => $view,
'id' => $id, 'id' => $id,

View File

@ -112,7 +112,7 @@ abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
->getForm() ->getForm()
->createView(); ->createView();
$this->assertEquals('messages', $view['child']->vars['translation_domain']); $this->assertNull($view['child']->vars['translation_domain']);
} }
public function testPassLabelToView() public function testPassLabelToView()