Skip to content

Commit

Permalink
Make CSRF extension work with Validator translations domain
Browse files Browse the repository at this point in the history
  • Loading branch information
hkdobrev authored and fabpot committed Feb 25, 2018
1 parent 079e714 commit f4e231e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion FormServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public function register(Container $app)

$app['form.extension.csrf'] = function ($app) {
if (isset($app['translator'])) {
return new CsrfExtension($app['csrf.token_manager'], $app['translator']);
$translationDomain = isset($app['validator.translation_domain']) ? $app['validator.translation_domain'] : null;

return new CsrfExtension($app['csrf.token_manager'], $app['translator'], $translationDomain);
}

return new CsrfExtension($app['csrf.token_manager']);
Expand Down
6 changes: 5 additions & 1 deletion ValidatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function register(Container $app)
$app['validator.builder'] = function ($app) {
$builder = Validation::createValidatorBuilder();
$builder->setConstraintValidatorFactory($app['validator.validator_factory']);
$builder->setTranslationDomain('validators');
$builder->setTranslationDomain($app['validator.translation_domain']);
$builder->addObjectInitializers($app['validator.object_initializers']);
$builder->setMetadataFactory($app['validator.mapping.class_metadata_factory']);
if (isset($app['translator'])) {
Expand All @@ -58,5 +58,9 @@ public function register(Container $app)
};

$app['validator.validator_service_ids'] = [];

$app['validator.translation_domain'] = function () {
return 'validators';
};
}
}

0 comments on commit f4e231e

Please sign in to comment.