1 | <?php |
||
18 | abstract class AbstractEntityValidator extends AbstractValidator |
||
19 | { |
||
20 | /** |
||
21 | * EntityService instance used for validation |
||
22 | * |
||
23 | * @var EntityServiceInterface |
||
24 | */ |
||
25 | protected $entityService; |
||
26 | |||
27 | /** |
||
28 | * method name that will be called on validation |
||
29 | * |
||
30 | * @var string Method to be called |
||
31 | */ |
||
32 | protected $method = 'findBy'; |
||
33 | |||
34 | /** |
||
35 | * @var string Name of the field to search |
||
36 | */ |
||
37 | protected $field = 'id'; |
||
38 | |||
39 | /** |
||
40 | * Set entity service used for validation |
||
41 | * |
||
42 | * @param EntityServiceInterface $entityService |
||
43 | */ |
||
44 | 15 | public function setEntityService(EntityServiceInterface $entityService) |
|
48 | |||
49 | /** |
||
50 | * Sets the method option. |
||
51 | * |
||
52 | * @param string $method The name of the method to set. |
||
53 | */ |
||
54 | 9 | public function setMethod($method) |
|
58 | |||
59 | /** |
||
60 | * Sets the field option. |
||
61 | * |
||
62 | * @param string $field The name of the field to set. |
||
63 | */ |
||
64 | 3 | public function setField($field) |
|
68 | |||
69 | /** |
||
70 | * Will call the configured method on self::$entityService using the value as criteria |
||
71 | * |
||
72 | * @param mixed $value |
||
73 | * @return object |
||
74 | */ |
||
75 | 21 | protected function fetchResult($value) |
|
87 | } |
||
88 |