DummyStreamWrapper.php 882 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\LocalStream;

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

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

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

28
  function getDirectoryPath() {
29
    return \Drupal::service('site.path') . '/files';
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
  }

  /**
   * Override getInternalUri().
   *
   * Return a dummy path for testing.
   */
  function getInternalUri() {
    return '/dummy/example.txt';
  }

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