PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / composer / installers / src / Composer / Installers / MicroweberInstaller.php

MicroweberInstaller.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, 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