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

Improve projectname determination

Provide access to option values of this plugin to other plugins
parent e6fb9544
......@@ -16,6 +16,11 @@ use Symfony\Component\Yaml\Yaml;
*/
class Handler extends BaseHandler {
/**
* @var array
*/
protected $options;
/**
* Configure Drupal Project for Docker.
*
......@@ -189,93 +194,104 @@ class Handler extends BaseHandler {
/**
* Retrieve options from composer.json "extra" configuration.
*
* @param null $key
* Optional name of an option to be received instead of the full set of options.
*
* @return array
* The options.
*/
protected function getOptions() {
$projectname = str_replace([' ', '-', '_', '.'], '', basename(getcwd()));
$env = new Dotenv('docker4drupal', $this->io);
$env->put('COMPOSE_PROJECT_NAME', $projectname);
$extra = $this->composer->getPackage()->getExtra() + ['docker4drupal' => []];
$options = NestedArray::mergeDeep([
'projectname' => $projectname,
'docker0' => [
'ip' => $this->getLocalIpv4('docker0'),
],
'live' => [
'root' => '',
'uri' => '',
'host' => '',
'user' => $env->receive('live_host_username', 'Remote username for host of the live site', getenv('USER')),
],
'drush' => [
'sql' => [
'tables' => [
'structure' => [
'cache',
'cache_*',
'history',
'search_*',
'sessions',
'watchdog',
],
'skip' => [
'migration_*',
public function getOptions($key = NULL) {
if ($this->options === NULL) {
$env = new Dotenv('docker4drupal', $this->io);
$projectname = getenv('COMPOSE_PROJECT_NAME');
if (empty($projectname)) {$projectname = str_replace([' ', '-', '_', '.'], '', basename(getcwd()));
$env->put('COMPOSE_PROJECT_NAME', $projectname);
}
$extra = $this->composer->getPackage()->getExtra() + ['docker4drupal' => []];
$options = NestedArray::mergeDeep([
'projectname' => $projectname,
'docker0' => [
'ip' => $this->getLocalIpv4('docker0'),
],
'live' => [
'root' => '',
'uri' => '',
'host' => '',
'user' => $env->receive('live_host_username', 'Remote username for host of the live site', getenv('USER')),
],
'drush' => [
'sql' => [
'tables' => [
'structure' => [
'cache',
'cache_*',
'history',
'search_*',
'sessions',
'watchdog',
],
'skip' => [
'migration_*',
],
],
],
],
],
'drupal' => [
'version' => '8',
],
'php' => [
'version' => '7.0',
'xdebug' => 1,
],
'webserver' => [
'type' => 'apache',
],
'varnish' => [
'enable' => 0,
],
'redis' => [
'version' => '4.0',
],
'dbbrowser' => [
'type' => 'pma',
],
'solr' => [
'enable' => 0,
'version' => '6.6',
],
'node' => [
'enable' => 0,
'key' => '',
'path' => '',
],
'memcached' => [
'enable' => 0,
],
'rsyslog' => [
'enable' => 0,
],
'athenapdf' => [
'enable' => 0,
'key' => '',
],
'blackfire' => [
'enable' => 0,
'id' => '',
'token' => '',
],
'webgrind' => [
'enable' => 0,
],
'wkhtmltox' => [
'enable' => 0,
],
], $extra['docker4drupal']);
return $env->replaceEnvironmentVariables($options);
'drupal' => [
'version' => '8',
],
'php' => [
'version' => '7.0',
'xdebug' => 1,
],
'webserver' => [
'type' => 'apache',
],
'varnish' => [
'enable' => 0,
],
'redis' => [
'version' => '4.0',
],
'dbbrowser' => [
'type' => 'pma',
],
'solr' => [
'enable' => 0,
'version' => '6.6',
],
'node' => [
'enable' => 0,
'key' => '',
'path' => '',
],
'memcached' => [
'enable' => 0,
],
'rsyslog' => [
'enable' => 0,
],
'athenapdf' => [
'enable' => 0,
'key' => '',
],
'blackfire' => [
'enable' => 0,
'id' => '',
'token' => '',
],
'webgrind' => [
'enable' => 0,
],
'wkhtmltox' => [
'enable' => 0,
],
], $extra['docker4drupal']);
$this->options = $env->replaceEnvironmentVariables($options);
}
if ($key !== NULL) {
return $this->options[$key];
}
return $this->options;
}
/**
......
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