DummyPublicStreamWrapper.php

Same filename and directory in other branches
  1. 11.x core/modules/file/tests/file_test/src/StreamWrapper/DummyPublicStreamWrapper.php

Namespace

Drupal\file_test\StreamWrapper

File

core/modules/file/tests/file_test/src/StreamWrapper/DummyPublicStreamWrapper.php

View source
<?php

declare (strict_types=1);
namespace Drupal\file_test\StreamWrapper;

use Drupal\Core\Url;

/**
 * Helper class for testing the stream wrapper registry.
 *
 * Dummy stream wrapper implementation (dummy-public://).
 */
class DummyPublicStreamWrapper extends DummyStreamWrapper {
  
  /**
   * {@inheritdoc}
   */
  public function getExternalUrl() : string {
    $path = str_replace('\\', '/', $this->getTarget());
    return Url::fromRoute('file_test.public', [
      'filepath' => $path,
    ], [
      'absolute' => TRUE,
      'path_processing' => FALSE,
      'query' => [
        'file' => $path,
      ],
    ])->toString();
  }

}

Classes

Title Deprecated Summary
DummyPublicStreamWrapper Helper class for testing the stream wrapper registry.

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