Total Complexity | 10 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | class CheckoutComponentValidator extends RequiredFields |
||
14 | { |
||
15 | protected $config; |
||
16 | |||
17 | public function __construct(CheckoutComponentConfig $config) |
||
21 | } |
||
22 | |||
23 | public function php($data) |
||
24 | { |
||
25 | $valid = parent::php($data); |
||
26 | //do component validation |
||
27 | try { |
||
28 | $this->config->validateData($data); |
||
29 | } catch (ValidationException $e) { |
||
30 | $result = $e->getResult(); |
||
31 | foreach ($result->getMessages() as $message) { |
||
32 | if (!$this->fieldHasError($message['fieldName'])) { |
||
33 | $this->validationError($message['fieldName'], $message['message'], 'bad'); |
||
34 | } |
||
35 | } |
||
36 | $valid = false; |
||
37 | } |
||
38 | if (!$valid) { |
||
39 | $this->form->sessionMessage( |
||
40 | _t( |
||
41 | __CLASS__ . ".InvalidDataMessage", |
||
42 | "There are problems with the data you entered. See below:" |
||
43 | ), |
||
44 | "bad" |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | return $valid; |
||
49 | } |
||
50 | |||
51 | public function fieldHasError($field) |
||
61 | } |
||
62 | } |
||
63 |