public static function ScriptHandler::createRequiredFiles in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 9.0.x
Same name and namespace in other branches
- 8.8 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::createRequiredFiles()
- 8.4 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::createRequiredFiles()
- 8.5 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::createRequiredFiles()
- 8.6 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::createRequiredFiles()
- 8.7 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::createRequiredFiles()
Create required files.
Parameters
\Composer\EventDispatcher\Event $event: Event of create required files.
File
- src/
composer/ ScriptHandler.php, line 43
Class
- ScriptHandler
- Varbase Composer Script Handler.
Namespace
Varbase\composerCode
public static function createRequiredFiles(Event $event) {
$fs = new Filesystem();
$drupal_root = static::getDrupalRoot(getcwd());
$dirs = [
'modules',
'profiles',
'themes',
'libraries',
];
// Required for unit testing.
foreach ($dirs as $dir) {
if (!$fs
->exists($drupal_root . '/' . $dir)) {
$fs
->mkdir($drupal_root . '/' . $dir);
$fs
->touch($drupal_root . '/' . $dir . '/.gitkeep');
}
}
// Prepare the settings file for installation.
if (!$fs
->exists($drupal_root . '/sites/default/settings.php') and $fs
->exists($drupal_root . '/sites/default/default.settings.php')) {
$fs
->copy($drupal_root . '/sites/default/default.settings.php', $drupal_root . '/sites/default/settings.php');
$fs
->chmod($drupal_root . '/sites/default/settings.php', 0666);
$event
->getIO()
->write("Create a sites/default/settings.php file with chmod 0666");
}
// Prepare the services file for installation.
if (!$fs
->exists($drupal_root . '/sites/default/services.yml') and $fs
->exists($drupal_root . '/sites/default/default.services.yml')) {
$fs
->copy($drupal_root . '/sites/default/default.services.yml', $drupal_root . '/sites/default/services.yml');
$fs
->chmod($drupal_root . '/sites/default/services.yml', 0666);
$event
->getIO()
->write("Create a sites/default/services.yml file with chmod 0666");
}
// Create the files directory with chmod 0777.
if (!$fs
->exists($drupal_root . '/sites/default/files')) {
$oldmask = umask(0);
$fs
->mkdir($drupal_root . '/sites/default/files', 0777);
umask($oldmask);
$event
->getIO()
->write("Create a sites/default/files directory with chmod 0777");
}
}