Chris@0: query->get('file'); Chris@0: // Merge remaining path arguments into relative file path. Chris@0: $uri = $scheme . '://' . $target; Chris@0: Chris@0: if (file_stream_wrapper_valid_scheme($scheme) && file_exists($uri)) { Chris@0: // Let other modules provide headers and controls access to the file. Chris@0: $headers = $this->moduleHandler()->invokeAll('file_download', [$uri]); Chris@0: Chris@0: foreach ($headers as $result) { Chris@0: if ($result == -1) { Chris@0: throw new AccessDeniedHttpException(); Chris@0: } Chris@0: } Chris@0: Chris@0: if (count($headers)) { Chris@0: // \Drupal\Core\EventSubscriber\FinishResponseSubscriber::onRespond() Chris@0: // sets response as not cacheable if the Cache-Control header is not Chris@0: // already modified. We pass in FALSE for non-private schemes for the Chris@0: // $public parameter to make sure we don't change the headers. Chris@0: return new BinaryFileResponse($uri, 200, $headers, $scheme !== 'private'); Chris@0: } Chris@0: Chris@0: throw new AccessDeniedHttpException(); Chris@0: } Chris@0: Chris@0: throw new NotFoundHttpException(); Chris@0: } Chris@0: Chris@0: }