Backup of db before drupal security update
[yaffs-website] / web / core / modules / config / config.module
1 <?php
2
3 /**
4  * @file
5  * Allows site administrators to modify configuration.
6  */
7
8 use Drupal\Core\Routing\RouteMatchInterface;
9
10 /**
11  * Implements hook_help().
12  */
13 function config_help($route_name, RouteMatchInterface $route_match) {
14   switch ($route_name) {
15     case 'help.page.config':
16       $output = '';
17       $output .= '<h3>' . t('About') . '</h3>';
18       $output .= '<p>' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the <a href=":url">online documentation for the Configuration Manager module</a>.', [':url' => 'https://www.drupal.org/documentation/administer/config']) . '</p>';
19       $output .= '<h3>' . t('Uses') . '</h3>';
20       $output .= '<dl>';
21       $output .= '<dt>' . t('Exporting the full configuration') . '</dt>';
22       $output .= '<dd>' . t('You can create and download an archive consisting of all your site\'s configuration exported as <em>*.yml</em> files on the <a href=":url">Export</a> page.', [':url' => \Drupal::url('config.export_full')]) . '</dd>';
23       $output .= '<dt>' . t('Importing a full configuration') . '</dt>';
24       $output .= '<dd>' . t('You can upload a full site configuration from an archive file on the <a href=":url">Import</a> page. When importing data from a different environment, the site and import files must have matching configuration values for UUID in the <em>system.site</em> configuration item. That means that your other environments should initially be set up as clones of the target site. Migrations are not supported.', [':url' => \Drupal::url('config.import_full')]) . '</dd>';
25       $output .= '<dt>' . t('Synchronizing configuration') . '</dt>';
26       $output .= '<dd>' . t('You can review differences between the active configuration and an imported configuration archive on the <a href=":synchronize">Synchronize</a> page to ensure that the changes are as expected, before finalizing the import. The Synchronize page also shows configuration items that would be added or removed.', [':synchronize' => \Drupal::url('config.sync')]) . '</dd>';
27       $output .= '<dt>' . t('Exporting a single configuration item') . '</dt>';
28       $output .= '<dd>' . t('You can export a single configuration item by selecting a <em>Configuration type</em> and <em>Configuration name</em> on the <a href=":single-export">Single export</a> page. The configuration and its corresponding <em>*.yml file name</em> are then displayed on the page for you to copy.', [':single-export' => \Drupal::url('config.export_single')]) . '</dd>';
29       $output .= '<dt>' . t('Importing a single configuration item') . '</dt>';
30       $output .= '<dd>' . t('You can import a single configuration item by pasting it in YAML format into the form on the <a href=":single-import">Single import</a> page.', [':single-import' => \Drupal::url('config.import_single')]) . '</dd>';
31       $output .= '</dl>';
32       return $output;
33
34     case 'config.sync':
35       $output = '';
36       $output .= '<p>' . t('Compare the configuration uploaded to your sync directory with the active configuration before completing the import.') . '</p>';
37       return $output;
38
39     case 'config.export_full':
40       $output = '';
41       $output .= '<p>' . t('Export and download the full configuration of this site as a gzipped tar file.') . '</p>';
42       return $output;
43
44     case 'config.import_full':
45       $output = '';
46       $output .= '<p>' . t('Upload a full site configuration archive to the sync directory. It can then be compared and imported on the Synchronize page.') . '</p>';
47       return $output;
48
49     case 'config.export_single':
50       $output = '';
51       $output .= '<p>' . t('Choose a configuration item to display its YAML structure.') . '</p>';
52       return $output;
53
54     case 'config.import_single':
55       $output = '';
56       $output .= '<p>' . t('Import a single configuration item by pasting its YAML structure into the text field.') . '</p>';
57       return $output;
58   }
59 }
60
61 /**
62  * Implements hook_file_download().
63  */
64 function config_file_download($uri) {
65   $scheme = file_uri_scheme($uri);
66   $target = file_uri_target($uri);
67   if ($scheme == 'temporary' && $target == 'config.tar.gz') {
68     if (\Drupal::currentUser()->hasPermission('export configuration')) {
69       $request = \Drupal::request();
70       $date = DateTime::createFromFormat('U', $request->server->get('REQUEST_TIME'));
71       $date_string = $date->format('Y-m-d-H-i');
72       $hostname = str_replace('.', '-', $request->getHttpHost());
73       $filename = 'config' . '-' . $hostname . '-' . $date_string . '.tar.gz';
74       $disposition = 'attachment; filename="' . $filename . '"';
75       return [
76         'Content-disposition' => $disposition,
77       ];
78     }
79     return -1;
80   }
81 }