@@ 31-53 (lines=23) @@ | ||
28 | * |
|
29 | * @return self|$this|ParserInterface |
|
30 | */ |
|
31 | public function setData($definitions) |
|
32 | { |
|
33 | if (is_array($definitions)) { |
|
34 | $this->parsedData = $definitions; |
|
35 | return; |
|
36 | } |
|
37 | ||
38 | if (!is_file($definitions)) { |
|
39 | throw new InvalidArgumentException( |
|
40 | "The form definition file '{$definitions}' does not exists." |
|
41 | ); |
|
42 | } |
|
43 | ||
44 | try { |
|
45 | $this->parsedData = include $definitions; |
|
46 | } catch (\Exception $caught) { |
|
47 | throw new ParserErrorException( |
|
48 | 'Error parsing form definitions: '.$caught->getMessage(), |
|
49 | 0, |
|
50 | $caught |
|
51 | ); |
|
52 | } |
|
53 | } |
|
54 | } |
@@ 136-158 (lines=23) @@ | ||
133 | * |
|
134 | * @return self|$this|ParserInterface |
|
135 | */ |
|
136 | public function setData($definitions) |
|
137 | { |
|
138 | if (is_array($definitions)) { |
|
139 | $this->parsedData = $definitions; |
|
140 | return; |
|
141 | } |
|
142 | ||
143 | if (!is_file($definitions)) { |
|
144 | throw new InvalidArgumentException( |
|
145 | "The form definition file '{$definitions}' does not exists." |
|
146 | ); |
|
147 | } |
|
148 | ||
149 | try { |
|
150 | $this->parsedData = Yaml::parse(file_get_contents($definitions)); |
|
151 | } catch (\Exception $caught) { |
|
152 | throw new ParserErrorException( |
|
153 | 'Error parsing form definitions: '.$caught->getMessage(), |
|
154 | 0, |
|
155 | $caught |
|
156 | ); |
|
157 | } |
|
158 | } |
|
159 | } |