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
|
|
|
* @deprecated since 3.0.0, to be removed in 3.1 |
28
|
|
|
*/ |
29
|
|
|
class ValidatorServiceProvider implements ServiceProviderInterface |
30
|
|
|
{ |
31
|
|
|
public function register(Application $app) |
32
|
|
|
{ |
33
|
|
|
$app['validator'] = $app->share(function ($app) { |
34
|
|
|
|
35
|
|
|
return new Validator( |
36
|
|
|
$app['validator.mapping.class_metadata_factory'], |
37
|
|
|
$app['validator.validator_factory'], |
38
|
|
|
isset($app['translator']) ? $app['translator'] : new DefaultTranslator(), |
39
|
|
|
'validators', |
40
|
|
|
$app['validator.object_initializers'] |
41
|
|
|
); |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
$app['validator.mapping.class_metadata_factory'] = $app->share(function ($app) { |
|
|
|
|
45
|
|
|
return new ClassMetadataFactory(new StaticMethodLoader()); |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
$app['validator.validator_factory'] = $app->share(function () use ($app) { |
49
|
|
|
$validators = isset($app['validator.validator_service_ids']) ? $app['validator.validator_service_ids'] : array(); |
50
|
|
|
|
51
|
|
|
return new ConstraintValidatorFactory($app, $validators); |
52
|
|
|
}); |
53
|
|
|
|
54
|
|
|
$app['validator.object_initializers'] = $app->share(function ($app) { |
|
|
|
|
55
|
|
|
return array(); |
56
|
|
|
}); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function boot(Application $app) |
60
|
|
|
{ |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.