You are here

public function FeaturesController::downloadExport in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/Controller/FeaturesController.php \Drupal\features\Controller\FeaturesController::downloadExport()

Downloads a tarball of the site configuration.

Parameters

string $uri: The URI to download.

\Symfony\Component\HttpFoundation\Request $request: The request.

Return value

\Symfony\Component\HttpFoundation\BinaryFileResponse The downloaded file.

1 string reference to 'FeaturesController::downloadExport'
features.routing.yml in ./features.routing.yml
features.routing.yml

File

src/Controller/FeaturesController.php, line 65

Class

FeaturesController
Returns responses for config module routes.

Namespace

Drupal\features\Controller

Code

public function downloadExport($uri, Request $request) {
  if ($uri) {

    // @todo Simplify once https://www.drupal.org/node/2630920 is solved.
    if (!$this->csrfToken
      ->validate($request->query
      ->get('token'), $uri)) {
      throw new AccessDeniedHttpException();
    }
    $request = new Request([
      'file' => $uri,
    ]);
    return $this->fileDownloadController
      ->download($request, 'temporary');
  }
}