Skip to content

Commit 0d9bf4f

Browse files
authored
Add installer for TastyIgniter extensions and themes (#474)
* Add installer for TastyIgniter extensions and themes * CI fix * CI fix * CI fix * Add support for TastyIgniter themes * Use appropriate replace regex
1 parent 9d4e028 commit 0d9bf4f

File tree

6 files changed

+129
-0
lines changed

6 files changed

+129
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ is not needed to install packages with these frameworks:
113113
| Sylius | `sylius-theme`
114114
| symfony1 | **`symfony1-plugin`**
115115
| TAO | `tao-extension`
116+
| TastyIgniter | **`igniter-extension`<br>`igniter-theme`**
116117
| Tusk | `tusk-task`<br>`tusk-command`<br>`tusk-asset`
117118
| TYPO3 Flow | `typo3-flow-package`<br>`typo3-flow-framework`<br>`typo3-flow-plugin`<br>`typo3-flow-site`<br>`typo3-flow-boilerplate`<br>`typo3-flow-build`
118119
| TYPO3 CMS | `typo3-cms-extension` (Deprecated in this package, use the [TYPO3 CMS Installers](https://packagist.org/packages/typo3/cms-composer-installers) instead)

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"SyDES",
6969
"Sylius",
7070
"symfony",
71+
"TastyIgniter",
7172
"Thelia",
7273
"TYPO3",
7374
"WHMCS",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Composer\Installers;
4+
5+
class IgniterInstaller extends BaseInstaller
6+
{
7+
protected $locations = array(
8+
'extension' => 'extensions/{$vendor}/{$name}/',
9+
'theme' => 'themes/{$name}/',
10+
);
11+
12+
/**
13+
* Format package name.
14+
*
15+
* Cut off leading 'ti-ext-' or 'ti-theme-' if present.
16+
* Strip vendor name of characters that is not alphanumeric or an underscore
17+
*
18+
*/
19+
public function inflectPackageVars($vars)
20+
{
21+
if ($vars['type'] === 'igniter-extension') {
22+
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']);
23+
$vars['name'] = preg_replace('/^ti-ext-$/', '', $vars['name']);
24+
}
25+
26+
if ($vars['type'] === 'igniter-theme') {
27+
$vars['name'] = preg_replace('/^ti-theme-$/', '', $vars['name']);
28+
}
29+
30+
return $vars;
31+
}
32+
}

src/Composer/Installers/Installer.php

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Installer extends LibraryInstaller
5050
'fuelphp' => 'FuelphpInstaller',
5151
'grav' => 'GravInstaller',
5252
'hurad' => 'HuradInstaller',
53+
'igniter' => 'IgniterInstaller',
5354
'imagecms' => 'ImageCMSInstaller',
5455
'itop' => 'ItopInstaller',
5556
'joomla' => 'JoomlaInstaller',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
namespace Composer\Installers\Test;
4+
5+
use Composer\Composer;
6+
use Composer\Installers\IgniterInstaller;
7+
use Composer\Package\Package;
8+
use PHPUnit\Framework\TestCase as BaseTestCase;
9+
10+
class IgniterInstallerTest extends BaseTestCase
11+
{
12+
/**
13+
* @var IgniterInstaller
14+
*/
15+
private $installer;
16+
17+
/**
18+
* setUp
19+
*
20+
* @return void
21+
*/
22+
public function setUp()
23+
{
24+
$this->installer = new IgniterInstaller(
25+
new Package('NyanCat', '4.2', '4.2'),
26+
new Composer()
27+
);
28+
}
29+
30+
/**
31+
* @dataProvider packageNameInflectionProvider
32+
*
33+
* @return void
34+
*/
35+
public function testInflectPackageVars($type, $vendor, $name, $expectedVendor, $expectedName)
36+
{
37+
$this->assertEquals(
38+
$this->installer->inflectPackageVars(array(
39+
'vendor' => $vendor,
40+
'name' => $name,
41+
'type' => $type,
42+
)),
43+
array('vendor' => $expectedVendor, 'name' => $expectedName, 'type' => $type)
44+
);
45+
}
46+
47+
public function packageNameInflectionProvider()
48+
{
49+
return array(
50+
array(
51+
'igniter-extension',
52+
'acme',
53+
'pages',
54+
'acme',
55+
'pages',
56+
),
57+
array(
58+
'igniter-extension',
59+
'acme',
60+
'ti-ext-pages',
61+
'acme',
62+
'pages',
63+
),
64+
// tests vendor name containing a hyphen
65+
array(
66+
'igniter-extension',
67+
'foo-bar-co',
68+
'blog',
69+
'foobarco',
70+
'blog',
71+
),
72+
// tests that exactly one '-theme' is cut off
73+
array(
74+
'igniter-theme',
75+
'acme',
76+
'ti-theme-theme',
77+
'acme',
78+
'theme',
79+
),
80+
// tests that names without '-theme' suffix stay valid
81+
array(
82+
'igniter-theme',
83+
'acme',
84+
'someothertheme',
85+
'acme',
86+
'someothertheme',
87+
),
88+
);
89+
}
90+
}

tests/Composer/Installers/Test/InstallerTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ public function dataForTestSupport()
149149
array('fuelphp-component', true),
150150
array('hurad-plugin', true),
151151
array('hurad-theme', true),
152+
array('igniter-extension', true),
153+
array('igniter-theme', true),
152154
array('imagecms-template', true),
153155
array('imagecms-module', true),
154156
array('imagecms-library', true),
@@ -344,6 +346,8 @@ public function dataForTestInstallPath()
344346
array('fuelphp-component', 'components/demo/', 'fuelphp/demo'),
345347
array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'),
346348
array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'),
349+
array('igniter-extension', 'extensions/shama/my_extension/', 'shama/my_extension'),
350+
array('igniter-theme', 'themes/my_theme/', 'shama/my_theme'),
347351
array('imagecms-template', 'templates/my_template/', 'shama/my_template'),
348352
array('imagecms-module', 'application/modules/my_module/', 'shama/my_module'),
349353
array('imagecms-library', 'application/libraries/my_library/', 'shama/my_library'),

0 commit comments

Comments
 (0)