Skip to content
Snippets Groups Projects
Commit e6fb9544 authored by jurgenhaas's avatar jurgenhaas
Browse files

Refactor namespace to extend LakeDrops Composer Components

parent e66746e7
No related branches found
Tags v1.8.0
No related merge requests found
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
"require": { "require": {
"php": ">=5.6", "php": ">=5.6",
"composer-plugin-api": "^1.0.0", "composer-plugin-api": "^1.0.0",
"lakedrops/composer-scripts": "^1.0.0", "lakedrops/composer-scripts": "^1.1.0",
"lakedrops/docker-traefik": "^1.1.0", "lakedrops/docker-traefik": "^1.1.0",
"lakedrops/dotenv": "^1.0.0", "lakedrops/dotenv": "^1.0.0",
"twig/twig": "^1.23.1" "twig/twig": "^1.23.1"
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
namespace LakeDrops\Docker4Drupal; namespace LakeDrops\Docker4Drupal;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Script\Event; use Composer\Script\Event;
use LakeDrops\Component\Composer\BaseHandler;
use LakeDrops\Component\Dotenv\Dotenv; use LakeDrops\Component\Dotenv\Dotenv;
use LakeDrops\DockerTraefik\Traefik; use LakeDrops\DockerTraefik\Traefik;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
...@@ -15,67 +14,7 @@ use Symfony\Component\Yaml\Yaml; ...@@ -15,67 +14,7 @@ use Symfony\Component\Yaml\Yaml;
* *
* @package LakeDrops\Docker4Drupal * @package LakeDrops\Docker4Drupal
*/ */
class Handler { class Handler extends BaseHandler {
/**
* The composer object of this session.
*
* @var \Composer\Composer
*/
protected $composer;
/**
* The input-output object of the composer session.
*
* @var \Composer\IO\IOInterface
*/
protected $io;
/**
* The Drupal core package.
*
* @var \Composer\Package\PackageInterface
*/
protected $drupalCorePackage;
/**
* Handler constructor.
*
* @param \Composer\Composer $composer
* The composer object of this session.
* @param \Composer\IO\IOInterface $io
* The input-output object of the composer session.
*/
public function __construct(Composer $composer, IOInterface $io) {
$this->composer = $composer;
$this->io = $io;
}
/**
* Look up the Drupal core package object.
*
* @return \Composer\Package\PackageInterface
* The Drupal core package.
*/
protected function getDrupalCorePackage() {
if (!isset($this->drupalCorePackage)) {
$this->drupalCorePackage = $this->getPackage('drupal/core');
}
return $this->drupalCorePackage;
}
/**
* Retrieve a package from the current composer process.
*
* @param string $name
* Name of the package to get from the current composer installation.
*
* @return \Composer\Package\PackageInterface
* The package.
*/
protected function getPackage($name) {
return $this->composer->getRepositoryManager()->getLocalRepository()->findPackage($name, '*');
}
/** /**
* Configure Drupal Project for Docker. * Configure Drupal Project for Docker.
...@@ -84,6 +23,10 @@ class Handler { ...@@ -84,6 +23,10 @@ class Handler {
* The event that triggered the call of this function. * The event that triggered the call of this function.
* @param bool $overwrite * @param bool $overwrite
* Whether to overwrite existing config files. * Whether to overwrite existing config files.
*
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/ */
public function configureProject(Event $event, $overwrite = FALSE) { public function configureProject(Event $event, $overwrite = FALSE) {
...@@ -335,16 +278,6 @@ class Handler { ...@@ -335,16 +278,6 @@ class Handler {
return $env->replaceEnvironmentVariables($options); return $env->replaceEnvironmentVariables($options);
} }
/**
* Wrapper for git command in the root directory.
*
* @param string $command
* Git command name, arguments and/or options.
*/
protected function git($command) {
passthru(escapeshellcmd('git -c "user.email=d8-project@lakedrops.com" ' . $command));
}
/** /**
* Determine local ipv4 address. * Determine local ipv4 address.
* *
......
...@@ -2,30 +2,20 @@ ...@@ -2,30 +2,20 @@
namespace LakeDrops\Docker4Drupal; namespace LakeDrops\Docker4Drupal;
use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event; use Composer\Script\Event;
use Composer\Script\ScriptEvents; use Composer\Script\ScriptEvents;
use LakeDrops\Component\Composer\BasePlugin;
/** /**
* Composer plugin for handling docker4drupal setup. * Composer plugin for handling docker4drupal setup.
*/ */
class Plugin implements PluginInterface, EventSubscriberInterface { class Plugin extends BasePlugin {
/**
* The handler object to configure the project for docker.
*
* @var \LakeDrops\Docker4Drupal\Handler
*/
protected $handler;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function activate(Composer $composer, IOInterface $io) { public function getHandlerClass() {
$this->handler = new Handler($composer, $io); return Handler::class;
} }
/** /**
...@@ -54,6 +44,10 @@ class Plugin implements PluginInterface, EventSubscriberInterface { ...@@ -54,6 +44,10 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
* *
* @param \Composer\Script\Event $event * @param \Composer\Script\Event $event
* The event that triggered the call of this function. * The event that triggered the call of this function.
*
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/ */
public static function config(Event $event) { public static function config(Event $event) {
$handler = new Handler($event->getComposer(), $event->getIO()); $handler = new Handler($event->getComposer(), $event->getIO());
......
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