You are here

protected function SiteSettingsForm::createRandomConfigDirectory in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php \Drupal\Core\Installer\Form\SiteSettingsForm::createRandomConfigDirectory()
  2. 9 core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php \Drupal\Core\Installer\Form\SiteSettingsForm::createRandomConfigDirectory()

Create a random config sync directory.

Return value

string The path to the generated config sync directory.

1 call to SiteSettingsForm::createRandomConfigDirectory()
SiteSettingsForm::submitForm in core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php
Form submission handler.

File

core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php, line 285

Class

SiteSettingsForm
Provides a form to configure and rewrite settings.php.

Namespace

Drupal\Core\Installer\Form

Code

protected function createRandomConfigDirectory() {
  $config_sync_directory = $this->sitePath . '/files/config_' . Crypt::randomBytesBase64(55) . '/sync';

  // This should never fail, it is created here inside the public files
  // directory, which has already been verified to be writable itself.
  if (\Drupal::service('file_system')
    ->prepareDirectory($config_sync_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {

    // Put a README.txt into the sync config directory. This is required so
    // that they can later be added to git. Since this directory is
    // auto-created, we have to write out the README rather than just adding
    // it to the drupal core repo.
    $text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.' . ' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
    file_put_contents($config_sync_directory . '/README.txt', $text);
  }
  return $config_sync_directory;
}