|
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) |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
$app['validator'] = $app->share(function ($app) { |
|
32
|
|
|
|
|
33
|
|
|
return new Validator( |
|
|
|
|
|
|
34
|
369 |
|
$app['validator.mapping.class_metadata_factory'], |
|
35
|
369 |
|
$app['validator.validator_factory'], |
|
36
|
|
|
isset($app['translator']) ? $app['translator'] : new DefaultTranslator(), |
|
|
|
|
|
|
37
|
369 |
|
'validators', |
|
38
|
369 |
|
$app['validator.object_initializers'] |
|
39
|
|
|
); |
|
40
|
|
|
}); |
|
41
|
|
|
|
|
42
|
|
|
$app['validator.mapping.class_metadata_factory'] = $app->share(function ($app) { |
|
|
|
|
|
|
43
|
|
|
return new ClassMetadataFactory(new StaticMethodLoader()); |
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
53
|
369 |
|
return array(); |
|
54
|
|
|
}); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
639 |
|
public function boot(Application $app) |
|
|
|
|
|
|
58
|
|
|
{ |
|
59
|
639 |
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|