Commit e6fb9544 authored by Jürgen Haas's avatar Jürgen Haas

Refactor namespace to extend LakeDrops Composer Components

parent e66746e7
......@@ -26,7 +26,7 @@
"require": {
"php": ">=5.6",
"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/dotenv": "^1.0.0",
"twig/twig": "^1.23.1"
......
......@@ -2,9 +2,8 @@
namespace LakeDrops\Docker4Drupal;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Script\Event;
use LakeDrops\Component\Composer\BaseHandler;
use LakeDrops\Component\Dotenv\Dotenv;
use LakeDrops\DockerTraefik\Traefik;
use Symfony\Component\Filesystem\Filesystem;
......@@ -15,67 +14,7 @@ use Symfony\Component\Yaml\Yaml;
*
* @package LakeDrops\Docker4Drupal
*/
class Handler {
/**
* 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, '*');
}
class Handler extends BaseHandler {
/**
* Configure Drupal Project for Docker.
......@@ -84,6 +23,10 @@ class Handler {
* The event that triggered the call of this function.
* @param bool $overwrite
* 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) {
......@@ -335,16 +278,6 @@ class Handler {
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.
*
......
......@@ -2,30 +2,20 @@
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\ScriptEvents;
use LakeDrops\Component\Composer\BasePlugin;
/**
* Composer plugin for handling docker4drupal setup.
*/
class Plugin implements PluginInterface, EventSubscriberInterface {
/**
* The handler object to configure the project for docker.
*
* @var \LakeDrops\Docker4Drupal\Handler
*/
protected $handler;
class Plugin extends BasePlugin {
/**
* {@inheritdoc}
*/
public function activate(Composer $composer, IOInterface $io) {
$this->handler = new Handler($composer, $io);
public function getHandlerClass() {
return Handler::class;
}
/**
......@@ -54,6 +44,10 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
*
* @param \Composer\Script\Event $event
* 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) {
$handler = new Handler($event->getComposer(), $event->getIO());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment