Skip to content

Commit e136db3

Browse files
committed
further improvements to the myadmin compserp plugin.. it should actually be usable now.. well heres hoping
1 parent 920c03a commit e136db3

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
}
1111
],
1212
"autoload": {
13-
"psr-0": {"detain\\": "include/"}
13+
"psr-0": {"MyAdmin\\": "include/"}
1414
},
1515
"require": {
1616
"composer-plugin-api": "^1.0"
1717
},
1818
"extra": {
19-
"class": "detain\\Composer\\TemplateInstallerPlugin"
19+
"class": "MyAdmin\\Composer\\TemplateInstallerPlugin"
2020
},
2121
"minimum-stability": "dev"
2222
}

include/Composer/Installer.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
<?php
2+
/*
3+
The InstallerInterface class defines the following methods (please see the source for the exact signature):
24
3-
namespace detain\Composer;
5+
supports(), here you test whether the passed type matches the name that you declared for this installer (see the example).
6+
isInstalled(), determines whether a supported package is installed or not.
7+
install(), here you can determine the actions that need to be executed upon installation.
8+
update(), here you define the behavior that is required when Composer is invoked with the update argument.
9+
uninstall(), here you can determine the actions that need to be executed when the package needs to be removed.
10+
getInstallPath(), this method should return the location where the package is to be installed, relative from the location of composer.json.
11+
*/
12+
13+
namespace MyAdmin\Composer;
414

515
use Composer\Package\PackageInterface;
616
use Composer\Installer\LibraryInstaller;
@@ -12,16 +22,12 @@ class TemplateInstaller extends LibraryInstaller
1222
*/
1323
public function getInstallPath(PackageInterface $package)
1424
{
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+
$strip = 'myadmin/template-';
26+
$cut = strlen($strip) - 1;
27+
$prefix = substr($package->getPrettyName(), 0, $cut);
28+
if ($strip !== $prefix)
29+
throw new \InvalidArgumentException("Unable to install template, myadmin templates should always start their package name with '{$strip}'");
30+
return 'public_html/templates/'.substr($package->getPrettyName(), $cut);
2531
}
2632

2733
/**

include/Composer/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace detain\Composer;
3+
namespace MyAdmin\Composer;
44

55
use Composer\Composer;
66
use Composer\IO\IOInterface;

0 commit comments

Comments
 (0)