You are here

public function SessionStreamWrapper::getExternalUrl in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::getExternalUrl()

Overrides getExternalUrl().

We have set up a helper function and menu entry to provide access to this key via HTTP; normally it would be accessible some other way.

Overrides StreamWrapperInterface::getExternalUrl

File

stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php, line 203

Class

SessionStreamWrapper
Example stream wrapper class to handle session:// streams.

Namespace

Drupal\stream_wrapper_example\StreamWrapper

Code

public function getExternalUrl() {
  $path = str_replace('\\', '/', $this
    ->getLocalPath());
  return Url::fromRoute('stream_wrapper_example.files.session', [
    'filepath' => $path,
    'scheme' => 'session',
  ], [
    'absolute' => TRUE,
  ])
    ->toString(FALSE);
}