Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
Zoddo committed May 17, 2015
1 parent a6790ed commit ab129dd
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.idea/
/composer.lock
/vendor/
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "phpbbfr/phpbb-translation-style-installer",
"type": "composer-plugin",
"description": "A composer plugin, to install phpbb-translation-style composer packages in styles/{style-name}/theme/{lang} directory instead of the default composer installation path which is in the vendor folder",
"keywords": ["composer", "plugin", "phpbb", "translation", "style"],
"license": "GPLv2",
"authors": [
{
"name": "Zoddo",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3",
"composer-plugin-api": "*"
},
"require-dev": {
"composer/composer": "dev-master"
},
"autoload": {
"psr-0": {"phpbbfr\\PhpbbTranslationStyleInstaller": "src/"}
},
"extra": {
"class": "phpbbfr\\PhpbbTranslationStyleInstaller\\Plugin",
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}
34 changes: 34 additions & 0 deletions src/phpbbfr/PhpbbTranslationStyleInstaller/Installer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace phpbbfr\PhpbbTranslationStyleInstaller;

use Composer\Installer\LibraryInstaller;
use Composer\Package\PackageInterface;

class Installer extends LibraryInstaller
{
public function getInstallPath(PackageInterface $package)
{
$extra = $package->getExtra();

if (empty($extra['phpbb-style']) || empty($extra['phpbb-language']))
{
$dir = preg_replace('#^([a-z0-9]+)-([a-z_]{2,})$#i', 'styles/$1/theme/$2', $package->getName());
if ($dir != $package->getName())
{
return $dir;
}
else
{
throw new \InvalidArgumentException('Invalid phpbb-translation-style composer package.');
}
}

return sprintf('styles/%s/theme/%s', $extra['phpbb-style'], $extra['phpbb-language']);
}

public function supports($packageType)
{
return $packageType == 'phpbb-translation-style';
}
}
16 changes: 16 additions & 0 deletions src/phpbbfr/PhpbbTranslationStyleInstaller/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace phpbbfr\PhpbbTranslationStyleInstaller;

use Composer\Plugin\PluginInterface;
use Composer\Composer;
use Composer\IO\IOInterface;

class Plugin implements PluginInterface
{
public function activate(Composer $composer, IOInterface $io)
{
$installer = new Installer($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
}
}

0 comments on commit ab129dd

Please sign in to comment.