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

Coding standard

parent a1b73df4
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,14 @@
"lakedrops/dotenv": "^0.1",
"php": ">=5.6"
},
"require-dev": {
"composer/composer": "^1.5.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
"drupal/coder": "^8.2",
"phpunit/phpunit": "^4.8.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"LakeDrops\\DorgFlow\\": "src/"
......@@ -36,9 +44,5 @@
},
"extra": {
"class": "LakeDrops\\DorgFlow\\Plugin"
},
"require-dev": {
"composer/composer": "dev-master",
"phpunit/phpunit": "^4.4.0"
}
}
......@@ -2,22 +2,30 @@
namespace LakeDrops\DorgFlow;
use Composer\Package\PackageInterface;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Script\Event as ScriptEvent;
use Composer\Script\Event;
use GitElephant\Repository;
use LakeDrops\Component\Dotenv\Dotenv;
use Symfony\Component\Filesystem\Filesystem;
/**
* Class Handler.
*
* @package LakeDrops\DorgFlow
*/
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;
......@@ -25,8 +33,10 @@ class Handler {
/**
* Handler constructor.
*
* @param Composer $composer
* @param IOInterface $io
* @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;
......@@ -39,7 +49,8 @@ class Handler {
* @param string $name
* Name of the package to get from the current composer installation.
*
* @return PackageInterface
* @return \Composer\Package\PackageInterface
* The package.
*/
protected function getPackage($name) {
return $this->composer->getRepositoryManager()->getLocalRepository()->findPackage($name, '*');
......@@ -48,11 +59,12 @@ class Handler {
/**
* Post install/update event to prepare projects for development.
*
* @param ScriptEvent $event
* @param \Composer\Script\Event $event
* The event that triggered the call of this function.
*/
public function prepareDevProjects($event) {
public function prepareDevProjects(Event $event) {
// We only do the fancy stuff for developers
// We only do the fancy stuff for developers.
if (!$event->isDevMode()) {
return;
}
......@@ -77,9 +89,10 @@ class Handler {
}
/**
* Retrieve excludes from optional "extra" configuration.
* Retrieve options from composer.json "extra" configuration.
*
* @return array
* The options.
*/
protected function getOptions() {
$env = new Dotenv('dorgflow', $this->io);
......@@ -92,13 +105,22 @@ class Handler {
}
/**
* @inheritDoc
* Prepare the working directory of a git based package for dorgflow.
*
* @param string $path
* Name of the working directory.
* @param string $project
* Name of the project.
* @param string $version
* Version to checkout.
* @param string $username
* Username on drupal.org.
*/
protected function prepareWorkingDirectory($path, $project, $version, $username) {
list(, $projectname) = explode('/', $project);
$uri = $username . '@git.drupal.org:project/' . $projectname . '.git';
// Git Clone the repository into the working directory
// Git Clone the repository into the working directory.
$repository = Repository::open($path);
$repository->init();
......@@ -110,7 +132,7 @@ class Handler {
}
}
catch (\Exception $ex) {
// ignore the exception and conitue setup.
// Ignore the exception and conitue setup.
}
$fs = new Filesystem();
......
......@@ -6,6 +6,7 @@ use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
/**
......@@ -14,6 +15,8 @@ use Composer\Script\ScriptEvents;
class Plugin implements PluginInterface, EventSubscriberInterface {
/**
* The handler object to configure the project for dorgflow.
*
* @var \LakeDrops\DorgFlow\Handler
*/
protected $handler;
......@@ -39,8 +42,9 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
* Post install/update event callback.
*
* @param \Composer\Script\Event $event
* The event that triggered the call of this function.
*/
public function prepareDevProjects($event) {
public function prepareDevProjects(Event $event) {
$this->handler->prepareDevProjects($event);
}
......@@ -48,8 +52,9 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
* Script callback for putting in composer scripts to prepare the project.
*
* @param \Composer\Script\Event $event
* The event that triggered the call of this function.
*/
public static function prepare($event) {
public static function prepare(Event $event) {
$handler = new Handler($event->getComposer(), $event->getIO());
$handler->prepareDevProjects($event);
}
......
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