Skip to content

Commit

Permalink
Merge pull request #34 from ramsalt/feature/phpcs_suggestions
Browse files Browse the repository at this point in the history
Feature/phpcs suggestions
  • Loading branch information
jfauske authored Dec 10, 2024
2 parents 7b93a67 + 2a062ae commit 6447e26
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions drush/Commands/PolicyCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ public function rsyncValidate(CommandData $commandData) {
throw new \Exception(dt('Per !file, you may never rsync to the production site.', ['!file' => __FILE__]));
}
}

}
1 change: 1 addition & 0 deletions load.environment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* @file
* This file is included very early. See autoload.files in composer.json and
* https://getcomposer.org/doc/04-schema.md#files
*/
Expand Down
36 changes: 25 additions & 11 deletions scripts/composer/ScriptHandler.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?php

/**
* @file
* Contains \DrupalProject\composer\ScriptHandler.
*/

namespace DrupalProject\composer;

use Composer\Script\Event;
Expand All @@ -14,8 +9,27 @@
use DrupalFinder\DrupalFinderComposerRuntime;
use Symfony\Component\Filesystem\Filesystem;

/**
* Handles various script events during the Composer lifecycle for Drupal projects.
*
* This class provides static methods to create necessary files and directories
* for Drupal installations and checks for Composer version compatibility.
*/
class ScriptHandler {

/**
* Creates required Drupal directories and files to ensure proper installation.
*
* This method sets up necessary directories (`modules`, `profiles`, `themes`)
* and prepares essential configuration files like `settings.php`. It ensures
* these components are in place for successful Drupal setup and permissions
* are properly set for installation.
*
* @param \Composer\Script\Event $event
* The event object for handling script events.
*
* @return void
*/
public static function createRequiredFiles(Event $event) {
$fs = new Filesystem();
$drupalFinder = new DrupalFinderComposerRuntime();
Expand All @@ -32,15 +46,15 @@ public static function createRequiredFiles(Event $event) {
'themes',
];

// Required for unit testing
// Required for unit testing.
foreach ($dirs as $dir) {
if (!$fs->exists($drupalRoot . '/'. $dir)) {
$fs->mkdir($drupalRoot . '/'. $dir);
$fs->touch($drupalRoot . '/'. $dir . '/.gitkeep');
if (!$fs->exists($drupalRoot . '/' . $dir)) {
$fs->mkdir($drupalRoot . '/' . $dir);
$fs->touch($drupalRoot . '/' . $dir . '/.gitkeep');
}
}

// Prepare the settings file for installation
// Prepare the settings file for installation.
if (!$fs->exists($drupalRoot . '/sites/default/settings.php') && $fs->exists($drupalRoot . '/sites/default/default.settings.php')) {
$fs->copy($drupalRoot . '/sites/default/default.settings.php', $drupalRoot . '/sites/default/settings.php');
require_once $drupalRoot . '/core/includes/bootstrap.inc';
Expand All @@ -55,7 +69,7 @@ public static function createRequiredFiles(Event $event) {
$event->getIO()->write("Created a sites/default/settings.php file with chmod 0666");
}

// Create the files directory with chmod 0777
// Create the files directory with chmod 0777.
if (!$fs->exists($drupalRoot . '/sites/default/files') && !is_link($drupalRoot . '/sites/default/files')) {
$oldmask = umask(0);
$fs->mkdir($drupalRoot . '/sites/default/files', 0777);
Expand Down

0 comments on commit 6447e26

Please sign in to comment.