Newer
Older
<?php
namespace LakeDrops\Component\Composer;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Script\Event;
use Symfony\Component\Console\Input\InputInterface;
/**
* Class BaseHandler.
*
* @package LakeDrops\Component\Composer
*/
abstract class BaseHandler implements BaseHandlerInterface {
/**
* 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;
/**
* @var \Symfony\Component\Console\Input\InputInterface
*/
protected $input;
/**
* The event that triggered the action.
*
* @var \Composer\Script\Event
*/
protected $event;
/**
* 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;
}
/**
* {@inheritdoc}
*/
public function setEvent(Event $event) {
$this->event = $event;
return $this;
}
/**
* {@inheritdoc}
*/
public function setInput(InputInterface $input) {
$this->input = $input;
return $this;
}
if (!isset($this->drupalCorePackage)) {
$this->drupalCorePackage = $this->getPackage('drupal/core');
}
return $this->drupalCorePackage;
}
/**
return $this->composer->getRepositoryManager()->getLocalRepository()->findPackage($name, '*');
}
public function isDevMode(): bool {
if ($this->event !== NULL) {
return $this->event->isDevMode();
}
if ($this->input !== NULL) {
return !$this->input->hasOption('no-dev');
}
return FALSE;
}
public function isLocalDevMode(): bool {
$local_dev_mode = getenv('LAKEDROPS_DEV_ENV');
return !empty($local_dev_mode);
}
public function isCiContext(): bool {
$ci_project_dir = getenv('CI_PROJECT_DIR');
Utils::git($command);
/**
* {@inheritdoc}
*/
public function gitIgnore($pattern) {
Utils::gitIgnore($pattern);