function DummyPrivateStreamWrapper::getExternalUrl

Same name and namespace in other branches
  1. main core/modules/file/tests/file_test/src/StreamWrapper/DummyPrivateStreamWrapper.php \Drupal\file_test\StreamWrapper\DummyPrivateStreamWrapper::getExternalUrl()

Override getExternalUrl().

Return the HTML URI of a public file.

Overrides DummyStreamWrapper::getExternalUrl

File

core/modules/file/tests/file_test/src/StreamWrapper/DummyPrivateStreamWrapper.php, line 19

Class

DummyPrivateStreamWrapper
Helper class for testing the stream wrapper registry.

Namespace

Drupal\file_test\StreamWrapper

Code

public function getExternalUrl() : string {
  $path = str_replace('\\', '/', $this->getTarget());
  return Url::fromRoute('file_test.dummy', [
    'filepath' => $path,
  ], [
    'absolute' => TRUE,
    'path_processing' => FALSE,
    'query' => [
      'file' => $path,
    ],
  ])->toString();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.