You are here

function demo_get_fileconfig in Demonstration site (Sandbox / Snapshot) 8

Same name and namespace in other branches
  1. 5 demo.admin.inc \demo_get_fileconfig()
  2. 6 demo.admin.inc \demo_get_fileconfig()
  3. 7 demo.admin.inc \demo_get_fileconfig()

Get the file directory information.

11 calls to demo_get_fileconfig()
ConfigDeleteConfirm::buildForm in src/Form/ConfigDeleteConfirm.php
.
DefaultController::demo_autocomplete in src/Controller/DefaultController.php
funtion to autocomplete the demo dump and save it to the dumppath declared in settings.php
DefaultController::demo_download in src/Controller/DefaultController.php
Funtion to download the dump file.
DemoDeleteConfirm::buildForm in src/Form/DemoDeleteConfirm.php
Form constructor.
DemoDeleteConfirm::submitForm in src/Form/DemoDeleteConfirm.php
Form submission handler.

... See full list

File

./demo.module, line 16

Code

function demo_get_fileconfig($filename = 'Set default value') {
  $fileconfig = [];

  // Build dump path.
  if (!file_stream_wrapper_valid_scheme('private')) {

    // @todo Temporarily throwing a form error here.
    // Don't break demo_profile.
    if (!defined('MAINTENANCE_MODE')) {
      \Drupal::messenger()
        ->addWarning(t('The <a href="../../config/media/file-system">private filesystem</a> must be configured in order to create or load snapshots.'));
    }
    return FALSE;
  }
  $fileconfig['path'] = 'private://' . \Drupal::config('demo.settings')
    ->get('demo_dump_path', 'demo');
  $fileconfig['dumppath'] = $fileconfig['path'];

  // Append site name if it is not included in file_directory_path() and if not
  // storing files in sites/all/files.
  $fileconfig['site'] = str_replace('sites', '', \Drupal::service('site.path'));

  // Check if directory exists.
  if (!\Drupal::service('file_system')
    ->prepareDirectory($fileconfig['dumppath'], FileSystemInterface::CREATE_DIRECTORY)) {
    return FALSE;
  }

  // Protect dump files.
  file_save_htaccess($fileconfig['path'], TRUE);

  // Build SQL filename.
  $fileconfig['sql'] = $filename . '.sql';
  $fileconfig['sqlfile'] = $fileconfig['dumppath'] . '/' . $fileconfig['sql'];

  // Build info filename.
  $fileconfig['info'] = $filename . '.info';
  $fileconfig['infofile'] = $fileconfig['dumppath'] . '/' . $fileconfig['info'];
  return $fileconfig;
}