Skip to content
Snippets Groups Projects
Commit 010c4abf authored by jurgenhaas's avatar jurgenhaas
Browse files

#3

- Introduce a new environment variable DRUPAL_LIVE defaulting to 0
- Overwrite settings files when scaffolding with this plugin in local development environment
- Add ahoy commands to switch between live and development mode
parent 32d0343e
No related branches found
No related tags found
No related merge requests found
ahoyapi: v2
commands:
drupal:
imports:
- ahoy.drupal.yml
usage: Drupal configurations
ahoyapi: v2
commands:
live:
cmd: |
DRUPAL_LIVE=1
echo "DRUPAL_LIVE=1" >>.env
env -i $(cat .env | xargs) >.env
composer lakedrops:scaffold --no-interaction
drush cr
usage: Turn live mode on
dev:
cmd: |
DRUPAL_LIVE=0
echo "DRUPAL_LIVE=0" >>.env
env -i $(cat .env | xargs) >.env
composer lakedrops:scaffold --no-interaction
drush cr
usage: Turn live mode off
...@@ -58,7 +58,7 @@ class Handler extends BaseHandler { ...@@ -58,7 +58,7 @@ class Handler extends BaseHandler {
'prefix' => '', 'prefix' => '',
], ],
'domain' => str_replace(['.', '-'], ['\\.', '\\-'], 'www.example.com'), 'domain' => str_replace(['.', '-'], ['\\.', '\\-'], 'www.example.com'),
'live' => FALSE, 'live' => !empty($this->env->receiveGlobal('DRUPAL_LIVE', 'Live mode', '0')),
]; ];
} }
...@@ -131,10 +131,11 @@ class Handler extends BaseHandler { ...@@ -131,10 +131,11 @@ class Handler extends BaseHandler {
$settings_files[] = 'development.services.yml'; $settings_files[] = 'development.services.yml';
} }
} }
$overwrite = $this->isLocalDevMode();
foreach ($settings_files as $template) { foreach ($settings_files as $template) {
$file = $projectRoot . '/settings/default/' . $template; $file = $projectRoot . '/settings/default/' . $template;
$link = $webRoot . '/sites/default/' . $template; $link = $webRoot . '/sites/default/' . $template;
if (!$fs->exists($link)) { if ($overwrite || !$fs->exists($link)) {
$rendered = $this->config->render($template, file_get_contents($pluginRoot . '/templates/' . $template . '.twig')); $rendered = $this->config->render($template, file_get_contents($pluginRoot . '/templates/' . $template . '.twig'));
file_put_contents($file, $rendered); file_put_contents($file, $rendered);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment