Skip to content

Commit 1c0cdf3

Browse files
Merge pull request #284 from piotr-cz/cockpit-module-installer
Add support for Cockpit CMS
2 parents b64af88 + ad40d9b commit 1c0cdf3

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ is not needed to install packages with these frameworks:
4343
| CakePHP 2+ | **`cakephp-plugin`**
4444
| Chef | `chef-cookbook`<br>`chef-role`
4545
| CCFramework | `ccframework-ship`<br>`ccframework-theme`
46+
| Cockpit | `cockpit-module`
4647
| CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module`
4748
| concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update`
4849
| Craft | `craft-plugin`

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"Bitrix",
1313
"CakePHP",
1414
"Chef",
15+
"Cockpit",
1516
"CodeIgniter",
1617
"concrete5",
1718
"Craft",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
namespace Composer\Installers;
3+
4+
class CockpitInstaller extends BaseInstaller
5+
{
6+
protected $locations = array(
7+
'module' => 'cockpit/modules/addons/{$name}/',
8+
);
9+
10+
/**
11+
* Format module name.
12+
*
13+
* Strip `module-` prefix from package name.
14+
*
15+
* @param array @vars
16+
*
17+
* @return array
18+
*/
19+
public function inflectPackageVars($vars)
20+
{
21+
if ($vars['type'] == 'cockpit-module') {
22+
return $this->inflectModuleVars($vars);
23+
}
24+
25+
return $vars;
26+
}
27+
28+
public function inflectModuleVars($vars)
29+
{
30+
$vars['name'] = ucfirst(preg_replace('/cockpit-/i', '', $vars['name']));
31+
32+
return $vars;
33+
}
34+
}

src/Composer/Installers/Installer.php

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Installer extends LibraryInstaller
2424
'cakephp' => 'CakePHPInstaller',
2525
'chef' => 'ChefInstaller',
2626
'ccframework' => 'ClanCatsFrameworkInstaller',
27+
'cockpit' => 'CockpitInstaller',
2728
'codeigniter' => 'CodeIgniterInstaller',
2829
'concrete5' => 'Concrete5Installer',
2930
'craft' => 'CraftInstaller',

tests/Composer/Installers/Test/InstallerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function dataForTestSupport()
100100
array('cakephp-plugin', true),
101101
array('chef-cookbook', true),
102102
array('chef-role', true),
103+
array('cockpit-module', true),
103104
array('codeigniter-app', false),
104105
array('codeigniter-library', true),
105106
array('codeigniter-third-party', true),
@@ -229,6 +230,7 @@ public function dataForTestInstallPath()
229230
array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
230231
array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),
231232
array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),
233+
array('cockpit-module', 'cockpit/modules/addons/My_module/', 'piotr-cz/cockpit-my_module'),
232234
array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
233235
array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
234236
array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'),

0 commit comments

Comments
 (0)