1 | <?php |
||
19 | class FormatService |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Bundle configuration |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | private $config; |
||
28 | |||
29 | /** |
||
30 | * @var \Twig_Environment |
||
31 | */ |
||
32 | private $twig; |
||
33 | |||
34 | /** |
||
35 | * @var ValidatorService |
||
36 | */ |
||
37 | private $validator; |
||
38 | |||
39 | /** |
||
40 | * FormatService constructor. |
||
41 | * |
||
42 | * @param $config |
||
43 | * @param \Twig_Environment $twig |
||
44 | * @param ValidatorService $validator |
||
45 | */ |
||
46 | 3 | public function __construct($config, \Twig_Environment $twig, ValidatorService $validator) |
|
52 | |||
53 | /** |
||
54 | * Formats the configured set of translation files |
||
55 | * |
||
56 | * @param SymfonyStyle $io |
||
57 | * @param string|null $fileName Name of single file to format |
||
58 | * |
||
59 | * @return array List of Errors |
||
60 | */ |
||
61 | 6 | public function format(SymfonyStyle $io = null, $fileName = null) |
|
93 | |||
94 | /** |
||
95 | * Create a set of files on which the formatting should be performed |
||
96 | * |
||
97 | * @param string|null $fileName |
||
98 | * |
||
99 | * @return File[] |
||
100 | */ |
||
101 | 6 | private function getPreparedFileset($fileName = null) |
|
126 | |||
127 | /** |
||
128 | * Formats a single translation file and updates its content |
||
129 | * |
||
130 | * @param File $file |
||
131 | * |
||
132 | * @throws DuplicateKeyException |
||
133 | * @throws \Symfony\Component\HttpFoundation\File\Exception\FileException |
||
134 | * @throws \Twig_Error_Loader |
||
135 | * @throws \Twig_Error_Runtime |
||
136 | * @throws \Twig_Error_Syntax |
||
137 | * @throws \Decline\TransformatBundle\Exception\NoTransUnitsFoundException |
||
138 | * @throws \Symfony\Component\Filesystem\Exception\FileNotFoundException |
||
139 | * @throws \Decline\TransformatBundle\Exception\InvalidSchemaException |
||
140 | */ |
||
141 | 4 | private function formatSingleFile(File $file) |
|
163 | |||
164 | /** |
||
165 | * Validates the given file and returns the sorted trans-units |
||
166 | * |
||
167 | * @param File $file |
||
168 | * |
||
169 | * @return array |
||
170 | * @throws DuplicateKeyException |
||
171 | * @throws InvalidSchemaException |
||
172 | * @throws NoTransUnitsFoundException |
||
173 | */ |
||
174 | 4 | private function getTransUnits(File $file) |
|
213 | |||
214 | /** |
||
215 | * The configured directory of the translation files |
||
216 | * |
||
217 | * @return mixed |
||
218 | */ |
||
219 | 6 | private function getDirectory() |
|
223 | |||
224 | /** |
||
225 | * The configured source language of the xliff files |
||
226 | * |
||
227 | * @return mixed |
||
228 | */ |
||
229 | 4 | private function getXliffSourceLanguage() |
|
233 | |||
234 | /** |
||
235 | * The configured namespace of the xliff files |
||
236 | * |
||
237 | * @return mixed |
||
238 | */ |
||
239 | 4 | private function getXliffNamespace() |
|
243 | } |
||
244 |