1 | <?php namespace Cviebrock\ImageValidator; |
||
6 | class ImageValidatorServiceProvider extends ServiceProvider |
||
7 | { |
||
8 | |||
9 | /** |
||
10 | * Indicates if loading of the provider is deferred. |
||
11 | * |
||
12 | * @var bool |
||
13 | */ |
||
14 | protected $defer = false; |
||
15 | |||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $rules = [ |
||
20 | 'image_size', |
||
21 | 'image_aspect', |
||
22 | ]; |
||
23 | |||
24 | /** |
||
25 | * Bootstrap the application events. |
||
26 | * |
||
27 | * @return void |
||
28 | */ |
||
29 | public function boot() |
||
30 | { |
||
31 | $this->loadTranslationsFrom(__DIR__ . '/../lang', 'image-validator'); |
||
32 | |||
33 | $messages = trans('image-validator::validation'); |
||
34 | |||
35 | $this->app->bind(ImageValidator::class, function($app) use ($messages) { |
||
36 | $validator = new ImageValidator($app['translator'], [], [], $messages); |
||
37 | |||
38 | if (isset($app['validation.presence'])) { |
||
39 | $validator->setPresenceVerifier($app['validation.presence']); |
||
40 | } |
||
41 | |||
42 | return $validator; |
||
43 | }); |
||
44 | |||
45 | $this->addNewRules(); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get the list of new rules being added to the validator. |
||
50 | * |
||
51 | * @return array |
||
52 | */ |
||
53 | public function getRules() |
||
57 | |||
58 | /** |
||
59 | * Add new rules to the validator. |
||
60 | */ |
||
61 | protected function addNewRules() |
||
67 | |||
68 | /** |
||
69 | * Extend the validator with new rules. |
||
70 | * |
||
71 | * @param string $rule |
||
72 | * @return void |
||
73 | */ |
||
74 | protected function extendValidator($rule) |
||
82 | } |
||
83 |