Skip to content

Commit

Permalink
Changes to usage of DrupalFinderComposerRuntime API in ScriptHandler (#…
Browse files Browse the repository at this point in the history
…677)

Co-authored-by: Alex Skrypnyk <[email protected]>
  • Loading branch information
jnoordsij and AlexSkrypnyk authored Jul 3, 2024
1 parent 265c3b1 commit e7d5c58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/composer/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
use Composer\Semver\Comparator;
use Drupal\Core\Site\Settings;
use Drupal\Core\Site\SettingsEditor;
use DrupalFinder\DrupalFinder;
use DrupalFinder\DrupalFinderComposerRuntime;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Path;

class ScriptHandler {

Expand All @@ -22,6 +22,11 @@ public static function createRequiredFiles(Event $event) {
$drupalFinder = new DrupalFinderComposerRuntime();
$drupalRoot = $drupalFinder->getDrupalRoot();

if (is_null($drupalRoot)) {
$event->getIO()->writeError('<error>Drupal root could not be detected.</error>');
exit(1);
}

$dirs = [
'modules',
'profiles',
Expand All @@ -43,7 +48,7 @@ public static function createRequiredFiles(Event $event) {
require_once $drupalRoot . '/core/includes/install.inc';
new Settings([]);
$settings['settings']['config_sync_directory'] = (object) [
'value' => '../config/sync',
'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot),
'required' => TRUE,
];
SettingsEditor::rewrite($drupalRoot . '/sites/default/settings.php', $settings);
Expand Down

0 comments on commit e7d5c58

Please sign in to comment.