Skip to content

Commit 5487616

Browse files
committed
Initial work on the new composer iisntaller plugin to handle installing things to there proper locations
0 parents  commit 5487616

4 files changed

Lines changed: 73 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "detain/myadmin_composer_plugin",
3+
"description": "A composer plugin to handle the various types of 3rd party software we deal with in MyAdmin",
4+
"type": "composer-plugin",
5+
"license": "GPL",
6+
"authors": [
7+
{
8+
"name": "Joe Huss",
9+
"email": "detain@interserver.net"
10+
}
11+
],
12+
"autoload"": {
13+
"psr-0": {"detain\\": "include/"}
14+
},
15+
"require": {
16+
"composer-plugin-api": "^1.0"
17+
},
18+
"extra": {
19+
"class": "detain\\Composer\\TemplateInstallerPlugin""
20+
},
21+
"minimum-stability": "dev"
22+
}

include/Composer/Installer.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace detain\Composer;
4+
5+
use Composer\Package\PackageInterface;
6+
use Composer\Installer\LibraryInstaller;
7+
8+
class TemplateInstaller extends LibraryInstaller
9+
{
10+
/**
11+
* {@inheritDoc}
12+
*/
13+
public function getInstallPath(PackageInterface $package)
14+
{
15+
$prefix = substr($package->getPrettyName(), 0, 23);
16+
if ('myadmin/template-' !== $prefix) {
17+
throw new \InvalidArgumentException(
18+
'Unable to install template, myadmin templates '
19+
.'should always start their package name with '
20+
.'"myadmin/template-"'
21+
);
22+
}
23+
24+
return 'data/templates/'.substr($package->getPrettyName(), 23);
25+
}
26+
27+
/**
28+
* {@inheritDoc}
29+
*/
30+
public function supports($packageType)
31+
{
32+
return 'myadmin-template' === $packageType;
33+
}
34+
}

include/Composer/Plugin.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace detain\Composer;
4+
5+
use Composer\Composer;
6+
use Composer\IO\IOInterface;
7+
use Composer\Plugin\PluginInterface;
8+
9+
class TemplateInstallerPlugin implements PluginInterface
10+
{
11+
public function activate(Composer $composer, IOInterface $io)
12+
{
13+
$installer = new TemplateInstaller($io, $composer);
14+
$composer->getInstallationManager()->addInstaller($installer);
15+
}
16+
}

0 commit comments

Comments
 (0)