Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/phpcs suggestions #34

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
*
jfauske marked this conversation as resolved.
Show resolved Hide resolved
* @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
Loading