1 | <?php |
||
8 | class TemplatesCollection |
||
9 | { |
||
10 | /** |
||
11 | * Path to directory where basic templates are. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $dir; |
||
16 | |||
17 | /** |
||
18 | * Array of available migration file templates. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $templates = []; |
||
23 | |||
24 | /** |
||
25 | * Constructor. |
||
26 | */ |
||
27 | public function __construct() |
||
37 | |||
38 | /** |
||
39 | * Register basic templates. |
||
40 | */ |
||
41 | public function registerBasicTemplates() |
||
97 | |||
98 | /** |
||
99 | * Register templates for automigrations. |
||
100 | */ |
||
101 | public function registerAutoTemplates() |
||
128 | |||
129 | /** |
||
130 | * Getter for registered templates. |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | public function all() |
||
138 | |||
139 | /** |
||
140 | * Dynamically register migration template. |
||
141 | * |
||
142 | * @param array $template |
||
143 | * |
||
144 | * @return void |
||
145 | */ |
||
146 | public function registerTemplate($template) |
||
154 | |||
155 | /** |
||
156 | * Path to the file where a template is located. |
||
157 | * |
||
158 | * @param string $name |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | public function getTemplatePath($name) |
||
166 | |||
167 | /** |
||
168 | * Find out template name from user input. |
||
169 | * |
||
170 | * @param string|null $template |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function selectTemplate($template) |
||
186 | |||
187 | /** |
||
188 | * Check template fields and normalize them. |
||
189 | * |
||
190 | * @param $template |
||
191 | * |
||
192 | * @return array |
||
193 | */ |
||
194 | protected function normalizeTemplateDuringRegistration($template) |
||
210 | |||
211 | /** |
||
212 | * Register template aliases. |
||
213 | * |
||
214 | * @param array $template |
||
215 | * @param array $aliases |
||
216 | * |
||
217 | * @return void |
||
218 | */ |
||
219 | protected function registerTemplateAliases($template, array $aliases = []) |
||
229 | } |
||
230 |