1 | <?php |
||
19 | class Initializer |
||
20 | { |
||
21 | /** |
||
22 | * @var array|TemplateInterface[] |
||
23 | */ |
||
24 | private $templates; |
||
25 | |||
26 | /** |
||
27 | * Add template to initializer |
||
28 | * |
||
29 | * @param string $name |
||
30 | * @param TemplateInterface $template |
||
31 | * |
||
32 | * @return Initializer |
||
33 | */ |
||
34 | 6 | public function addTemplate($name, TemplateInterface $template) |
|
40 | |||
41 | /** |
||
42 | * Get template names |
||
43 | * |
||
44 | * @return array |
||
45 | */ |
||
46 | public function getTemplateNames() |
||
47 | { |
||
48 | return array_keys($this->templates); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Initialize deployer in project |
||
53 | * |
||
54 | * @param string $template |
||
55 | * @param string $directory |
||
56 | * @param string $file |
||
57 | * @param array $params |
||
58 | * @return string The configuration file path |
||
59 | * |
||
60 | * @throws TemplateNotFoundException |
||
61 | */ |
||
62 | 6 | public function initialize($template, $directory, $file = 'deploy.php', $params = []) |
|
77 | |||
78 | /** |
||
79 | * Check the directory before initialize |
||
80 | * |
||
81 | * @param string $directory |
||
82 | * |
||
83 | * @throws IOException |
||
84 | */ |
||
85 | 5 | private function checkDirectoryBeforeInitialize($directory) |
|
114 | |||
115 | /** |
||
116 | * Check the file before initialize |
||
117 | * |
||
118 | * @param string $directory |
||
119 | * @param string $file |
||
120 | * |
||
121 | * @throws IOException |
||
122 | */ |
||
123 | 2 | private function checkFileBeforeInitialize($directory, $file) |
|
136 | } |
||
137 |