Completed
Push — master ( 078f7b...6ad7bc )
by Kentaro
30:09
created

ValidatorServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Silex framework.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Eccube\ServiceProvider;
13
14
use Silex\Application;
15
use Silex\ServiceProviderInterface;
16
use Silex\ConstraintValidatorFactory;
17
use Symfony\Component\Validator\Validator;
18
use Symfony\Component\Validator\DefaultTranslator;
19
use Symfony\Component\Validator\Mapping\ClassMetadataFactory;
20
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
21
22
/**
23
 * Symfony Validator component Provider.
24
 *
25
 * @author Fabien Potencier <[email protected]>
26
 */
27
class ValidatorServiceProvider implements ServiceProviderInterface
28
{
29 369
    public function register(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
30
    {
31
        $app['validator'] = $app->share(function ($app) {
32
33
            return new Validator(
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\Validator\Validator has been deprecated with message: since version 2.5, to be removed in 3.0. Use {@link Validator\RecursiveValidator} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
34 369
                $app['validator.mapping.class_metadata_factory'],
35 369
                $app['validator.validator_factory'],
36
                isset($app['translator']) ? $app['translator'] : new DefaultTranslator(),
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\Validator\DefaultTranslator has been deprecated with message: since version 2.7, to be removed in 3.0. Use Symfony\Component\Translation\IdentityTranslator instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
37 369
                'validators',
38 369
                $app['validator.object_initializers']
39
            );
40
        });
41
42
        $app['validator.mapping.class_metadata_factory'] = $app->share(function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
            return new ClassMetadataFactory(new StaticMethodLoader());
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\Valida...ng\ClassMetadataFactory has been deprecated with message: since version 2.5, to be removed in 3.0. Use {@link LazyLoadingMetadataFactory} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
44
        });
45
46
        $app['validator.validator_factory'] = $app->share(function () use ($app) {
47
            $validators = isset($app['validator.validator_service_ids']) ? $app['validator.validator_service_ids'] : array();
48
49
            return new ConstraintValidatorFactory($app, $validators);
50
        });
51
52 369
        $app['validator.object_initializers'] = $app->share(function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53 369
            return array();
54
        });
55
    }
56
57 639
    public function boot(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
58
    {
59 639
    }
60
}
61