Skip to content
Snippets Groups Projects
Unverified Commit d47885a4 authored by Daniel Seifert's avatar Daniel Seifert
Browse files

make compatible to Composer 2

parent 3194a2a7
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@
}
],
"require": {
"composer-plugin-api": "^1.0"
"composer-plugin-api": "^2.0"
},
"autoload": {
"psr-4": {
......
......@@ -60,7 +60,7 @@ class Translatable {
* @param string $type The package type: 'plugin', 'theme' or 'core'.
* @param string $slug The plugin/theme slug, E.g. 'query-monitor'. In case of core, this is 'wordpress'.
* @param string $version The package version.
* @param string $languages Array of the languages we are using.
* @param array $languages Array of the languages we are using.
* @param string $wpLanguageDir Full path to the language files target directory.
*/
public function __construct( $type, $slug, $version, $languages, $wpLanguageDir ) {
......
......@@ -3,7 +3,7 @@
namespace BJ\Wplang;
use Composer\Composer;
use Composer\Script\Event;
use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
......@@ -50,10 +50,19 @@ class Wplang implements PluginInterface, EventSubscriberInterface {
}
if ( ! empty( $extra['wordpress-language-dir'] ) ) {
$this->wpLanguageDir = dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/' . $extra['wordpress-language-dir'];
$this->wpLanguageDir = dirname( __DIR__, 4 ) . '/' . $extra['wordpress-language-dir'];
}
}
public function deactivate(Composer $composer, IOInterface $io)
{
// do nothing
}
public function uninstall(Composer $composer, IOInterface $io)
{
// do nothing
}
/**
* Subscribe to Composer events.
......@@ -77,7 +86,7 @@ class Wplang implements PluginInterface, EventSubscriberInterface {
* @param PackageEvent $event The package event object.
*/
public function onPackageAction( PackageEvent $event ) {
if ( 'update' === $event->getOperation()->getJobType() ) {
if ($event->getOperation() instanceof UpdateOperation) {
$package = $event->getOperation()->getTargetPackage();
} else {
$package = $event->getOperation()->getPackage();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment