PluginProbe
Code Snippets / 3.10.1
Code Snippets v3.10.1
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / vendor / composer / installers / src / Composer / Installers / MicroweberInstaller.php

MicroweberInstaller.php in Code Snippets 3.10.1, at vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php

146 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Composer\Installers;
4
5 class MicroweberInstaller extends BaseInstaller
6 {
7 /** @var array<string, string> */
8 protected $locations = array(
9 'module' => 'userfiles/modules/{$install_item_dir}/',
10 'module-skin' => 'userfiles/modules/{$install_item_dir}/templates/',
11 'template' => 'userfiles/templates/{$install_item_dir}/',
12 'element' => 'userfiles/elements/{$install_item_dir}/',
13 'vendor' => 'vendor/{$install_item_dir}/',
14 'components' => 'components/{$install_item_dir}/'
15 );
16
17 /**
18 * Format package name.
19 *
20 * For package type microweber-module, cut off a trailing '-module' if present
21 *
22 * For package type microweber-template, cut off a trailing '-template' if present.
23 */
24 public function inflectPackageVars(array $vars): array
25 {
26 if ($this->package->getTargetDir() !== null && $this->package->getTargetDir() !== '') {
27 $vars['install_item_dir'] = $this->package->getTargetDir();
28 } else {
29 $vars['install_item_dir'] = $vars['name'];
30 if ($vars['type'] === 'microweber-template') {
31 return $this->inflectTemplateVars($vars);
32 }
33 if ($vars['type'] === 'microweber-templates') {
34 return $this->inflectTemplatesVars($vars);
35 }
36 if ($vars['type'] === 'microweber-core') {
37 return $this->inflectCoreVars($vars);
38 }
39 if ($vars['type'] === 'microweber-adapter') {
40 return $this->inflectCoreVars($vars);
41 }
42 if ($vars['type'] === 'microweber-module') {
43 return $this->inflectModuleVars($vars);
44 }
45 if ($vars['type'] === 'microweber-modules') {
46 return $this->inflectModulesVars($vars);
47 }
48 if ($vars['type'] === 'microweber-skin') {
49 return $this->inflectSkinVars($vars);
50 }
51 if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') {
52 return $this->inflectElementVars($vars);
53 }
54 }
55
56 return $vars;
57 }
58
59 /**
60 * @param array<string, string> $vars
61 * @return array<string, string>
62 */
63 protected function inflectTemplateVars(array $vars): array
64 {
65 $vars['install_item_dir'] = $this->pregReplace('/-template$/', '', $vars['install_item_dir']);
66 $vars['install_item_dir'] = $this->pregReplace('/template-$/', '', $vars['install_item_dir']);
67
68 return $vars;
69 }
70
71 /**
72 * @param array<string, string> $vars
73 * @return array<string, string>
74 */
75 protected function inflectTemplatesVars(array $vars): array
76 {
77 $vars['install_item_dir'] = $this->pregReplace('/-templates$/', '', $vars['install_item_dir']);
78 $vars['install_item_dir'] = $this->pregReplace('/templates-$/', '', $vars['install_item_dir']);
79
80 return $vars;
81 }
82
83 /**
84 * @param array<string, string> $vars
85 * @return array<string, string>
86 */
87 protected function inflectCoreVars(array $vars): array
88 {
89 $vars['install_item_dir'] = $this->pregReplace('/-providers$/', '', $vars['install_item_dir']);
90 $vars['install_item_dir'] = $this->pregReplace('/-provider$/', '', $vars['install_item_dir']);
91 $vars['install_item_dir'] = $this->pregReplace('/-adapter$/', '', $vars['install_item_dir']);
92
93 return $vars;
94 }
95
96 /**
97 * @param array<string, string> $vars
98 * @return array<string, string>
99 */
100 protected function inflectModuleVars(array $vars): array
101 {
102 $vars['install_item_dir'] = $this->pregReplace('/-module$/', '', $vars['install_item_dir']);
103 $vars['install_item_dir'] = $this->pregReplace('/module-$/', '', $vars['install_item_dir']);
104
105 return $vars;
106 }
107
108 /**
109 * @param array<string, string> $vars
110 * @return array<string, string>
111 */
112 protected function inflectModulesVars(array $vars): array
113 {
114 $vars['install_item_dir'] = $this->pregReplace('/-modules$/', '', $vars['install_item_dir']);
115 $vars['install_item_dir'] = $this->pregReplace('/modules-$/', '', $vars['install_item_dir']);
116
117 return $vars;
118 }
119
120 /**
121 * @param array<string, string> $vars
122 * @return array<string, string>
123 */
124 protected function inflectSkinVars(array $vars): array
125 {
126 $vars['install_item_dir'] = $this->pregReplace('/-skin$/', '', $vars['install_item_dir']);
127 $vars['install_item_dir'] = $this->pregReplace('/skin-$/', '', $vars['install_item_dir']);
128
129 return $vars;
130 }
131
132 /**
133 * @param array<string, string> $vars
134 * @return array<string, string>
135 */
136 protected function inflectElementVars(array $vars): array
137 {
138 $vars['install_item_dir'] = $this->pregReplace('/-elements$/', '', $vars['install_item_dir']);
139 $vars['install_item_dir'] = $this->pregReplace('/elements-$/', '', $vars['install_item_dir']);
140 $vars['install_item_dir'] = $this->pregReplace('/-element$/', '', $vars['install_item_dir']);
141 $vars['install_item_dir'] = $this->pregReplace('/element-$/', '', $vars['install_item_dir']);
142
143 return $vars;
144 }
145 }
146