Newer
Older
<?php
namespace LakeDrops\Component\Composer;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;
use Composer\Script\Event;
use Symfony\Component\Console\Input\InputInterface;
*
* @package LakeDrops\Component\Composer
*/
abstract class BaseHandler implements BaseHandlerInterface {
/**
* The composer object of this session.
*
* @var \Composer\Composer
*/
/**
* The input-output object of the composer session.
*
* @var \Composer\IO\IOInterface
*/
/**
* The project config.
*
* @var \LakeDrops\Component\Composer\Config
*/
* @var \Symfony\Component\Console\Input\InputInterface
*/
/**
* The event that triggered the action.
*
* @var \Composer\Script\Event
*/
/**
* The Drupal core package.
*
* @var \Composer\Package\PackageInterface
*/
* @var \LakeDrops\Component\Composer\Dotenv
/**
* 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;
}
/**
* Initialize configuration.
*/
protected function init(): void {
$this->env = new Dotenv($this->configId(), $this->io);
$this->config = new Config($this->configId(), $this->configDefault(), $this->env);
$this->postInit();
}
*/
protected function configDefault(): array {
return [];
/**
* May be overwritten by implementing classes.
*/
protected function postInit(): void {}
* @return \LakeDrops\Component\Composer\Config
*/
public function getConfig(): Config {
$this->init();
return $this->config;
}
$this->event = $event;
return $this;
}
/**
* {@inheritdoc}
*/
public function setInput(InputInterface $input): BaseHandler {
if (!isset($this->drupalCorePackage)) {
$this->drupalCorePackage = $this->getPackage('drupal/core');
}
return $this->drupalCorePackage;
}
/**
public function getPackage(string $name): ?PackageInterface {
return $this->composer->getRepositoryManager()->getLocalRepository()->findPackage($name, '*');
}
public function isDevMode(): bool {
return $this->event->isDevMode();
}
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');
public function git(string $command, string $path = NULL): void {
Utils::git($command, $path);
/**
* {@inheritdoc}
*/
public function gitIgnore(string $pattern): void {
Utils::gitIgnore($pattern);
/**
* {@inheritdoc}
*
* @phpcs:disable Squiz.NamingConventions.VaildMethodName.NotCamelCaps
public function gitLfs(string $pattern): void {
Utils::gitLfs($pattern);