DummyReadOnlyStreamWrapper.php 980 Bytes
Newer Older
1 2
<?php

3
namespace Drupal\file_test\StreamWrapper;
4 5 6 7 8 9 10 11 12

use Drupal\Core\StreamWrapper\LocalReadOnlyStream;

/**
 * Helper class for testing the stream wrapper registry.
 *
 * Dummy stream wrapper implementation (dummy-readonly://).
 */
class DummyReadOnlyStreamWrapper extends LocalReadOnlyStream {
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return t('Dummy files (readonly)');
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return t('Dummy wrapper for simpletest (readonly).');
  }

28
  public function getDirectoryPath() {
29
    return \Drupal::getContainer()->getParameter('site.path') . '/files';
30 31 32 33 34 35 36
  }

  /**
   * Override getInternalUri().
   *
   * Return a dummy path for testing.
   */
37
  public function getInternalUri() {
38 39 40 41 42 43 44 45
    return '/dummy/example.txt';
  }

  /**
   * Override getExternalUrl().
   *
   * Return the HTML URI of a public file.
   */
46
  public function getExternalUrl() {
47 48
    return '/dummy/example.txt';
  }
49

50
}