function SessionStreamWrapper::getExternalUrl

Same name in other branches
  1. 8.x-1.x stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::getExternalUrl()
  2. 4.0.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

modules/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);
}