1
|
|
|
<?php |
2
|
|
|
namespace Composer\Installers; |
3
|
|
|
|
4
|
|
|
class WinterInstaller extends BaseInstaller |
5
|
|
|
{ |
6
|
|
|
protected $locations = array( |
7
|
|
|
'module' => 'modules/{$name}/', |
8
|
|
|
'plugin' => 'plugins/{$vendor}/{$name}/', |
9
|
|
|
'theme' => 'themes/{$name}/' |
10
|
|
|
); |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Format package name. |
14
|
|
|
* |
15
|
|
|
* For package type winter-plugin, cut off a trailing '-plugin' if present. |
16
|
|
|
* |
17
|
|
|
* For package type winter-theme, cut off a trailing '-theme' if present. |
18
|
|
|
* |
19
|
|
|
*/ |
20
|
|
|
public function inflectPackageVars($vars) |
21
|
|
|
{ |
22
|
|
|
if ($vars['type'] === 'winter-module') { |
23
|
|
|
return $this->inflectModuleVars($vars); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
if ($vars['type'] === 'winter-plugin') { |
27
|
|
|
return $this->inflectPluginVars($vars); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
if ($vars['type'] === 'winter-theme') { |
31
|
|
|
return $this->inflectThemeVars($vars); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
return $vars; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
protected function inflectModuleVars($vars) |
38
|
|
|
{ |
39
|
|
|
$vars['name'] = preg_replace('/^wn-|-module$/', '', $vars['name']); |
40
|
|
|
|
41
|
|
|
return $vars; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
protected function inflectPluginVars($vars) |
45
|
|
|
{ |
46
|
|
|
$vars['name'] = preg_replace('/^wn-|-plugin$/', '', $vars['name']); |
47
|
|
|
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']); |
48
|
|
|
|
49
|
|
|
return $vars; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected function inflectThemeVars($vars) |
53
|
|
|
{ |
54
|
|
|
$vars['name'] = preg_replace('/^wn-|-theme$/', '', $vars['name']); |
55
|
|
|
|
56
|
|
|
return $vars; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|