You are here

public static function ScriptHandler::postDrupalScaffoldProcedure in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.8

Same name and namespace in other branches
  1. 8.4 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::postDrupalScaffoldProcedure()
  2. 8.5 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::postDrupalScaffoldProcedure()
  3. 8.6 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::postDrupalScaffoldProcedure()
  4. 8.7 src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::postDrupalScaffoldProcedure()
  5. 9.0.x src/composer/ScriptHandler.php \Varbase\composer\ScriptHandler::postDrupalScaffoldProcedure()

Post Drupal Scaffold Procedure.

Parameters

\Composer\EventDispatcher\Event $event: The script event.

File

src/composer/ScriptHandler.php, line 140

Class

ScriptHandler
Varbase Composer Script Handler.

Namespace

Varbase\composer

Code

public static function postDrupalScaffoldProcedure(Event $event) {
  $fs = new Filesystem();
  $drupal_root = static::getDrupalRoot(getcwd());
  if ($fs
    ->exists($drupal_root . '/profiles/varbase/src/assets/robots-staging.txt')) {

    // Create staging robots file.
    copy($drupal_root . '/profiles/varbase/src/assets/robots-staging.txt', $drupal_root . '/robots-staging.txt');
  }
  if ($fs
    ->exists($drupal_root . '/.htaccess') && $fs
    ->exists($drupal_root . '/profiles/varbase/src/assets/htaccess_extra')) {

    // Alter .htaccess file.
    $htaccess_path = $drupal_root . '/.htaccess';
    $htaccess_lines = file($htaccess_path);
    $lines = [];
    foreach ($htaccess_lines as $line) {
      $lines[] = $line;
      if (strpos($line, "RewriteEngine on") !== FALSE) {
        $lines = array_merge($lines, file($drupal_root . '/profiles/varbase/src/assets/htaccess_extra'));
      }
    }
    file_put_contents($htaccess_path, $lines);
  }
  if ($fs
    ->exists($drupal_root . '/profiles/varbase/src/assets/development.services.yml')) {

    // Alter development.services.yml to have Varbase's Local development
    // services.
    copy($drupal_root . '/profiles/varbase/src/assets/development.services.yml', $drupal_root . '/sites/development.services.yml');
  }
}