config_file_download($uri)
Implements hook_file_download().
File
- core/modules/config/config.module, line 64
- Allows site administrators to modify configuration.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | function config_file_download( $uri ) { $scheme = file_uri_scheme( $uri ); $target = file_uri_target( $uri ); if ( $scheme == 'temporary' && $target == 'config.tar.gz' ) { if (\Drupal::currentUser()->hasPermission( 'export configuration' )) { $request = \Drupal::request(); $date = DateTime::createFromFormat( 'U' , $request ->server->get( 'REQUEST_TIME' )); $date_string = $date ->format( 'Y-m-d-H-i' ); $hostname = str_replace ( '.' , '-' , $request ->getHttpHost()); $filename = 'config' . '-' . $hostname . '-' . $date_string . '.tar.gz' ; $disposition = 'attachment; filename="' . $filename . '"' ; return array ( 'Content-disposition' => $disposition , ); } return -1; } } |
Please login to continue.