Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
Minor optimization in ValidatorServiceProvider
Browse files Browse the repository at this point in the history
ReflectionClass is only needed if a translator is present. Moving usage of it inside the related conditional means one less object instantiation.
  • Loading branch information
elazar committed Jul 8, 2014
1 parent 4f81347 commit 1aed8cd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Silex/Provider/ValidatorServiceProvider.php
Expand Up @@ -29,9 +29,8 @@ class ValidatorServiceProvider implements ServiceProviderInterface
public function register(Application $app)
{
$app['validator'] = $app->share(function ($app) {
$r = new \ReflectionClass('Symfony\Component\Validator\Validator');

if (isset($app['translator'])) {
$r = new \ReflectionClass('Symfony\Component\Validator\Validator');
$app['translator']->addResource('xliff', dirname($r->getFilename()).'/Resources/translations/validators.'.$app['locale'].'.xlf', $app['locale'], 'validators');
}

Expand Down

0 comments on commit 1aed8cd

Please sign in to comment.