class FlysystemBridge in Flysystem 8
Same name and namespace in other branches
- 7 src/FlysystemBridge.php \Drupal\flysystem\FlysystemBridge
- 3.x src/FlysystemBridge.php \Drupal\flysystem\FlysystemBridge
- 2.0.x src/FlysystemBridge.php \Drupal\flysystem\FlysystemBridge
- 3.0.x src/FlysystemBridge.php \Drupal\flysystem\FlysystemBridge
An adapter for Flysystem to StreamWrapperInterface.
Hierarchy
- class \Drupal\flysystem\FlysystemBridge extends \Twistor\FlysystemStreamWrapper implements StreamWrapperInterface uses StringTranslationTrait
Expanded class hierarchy of FlysystemBridge
2 files declare their use of FlysystemBridge
- FlysystemBridgeTest.php in tests/src/ Unit/ FlysystemBridgeTest.php 
- FlysystemServiceProviderTest.php in tests/src/ Unit/ FlysystemServiceProviderTest.php 
File
- src/FlysystemBridge.php, line 13 
Namespace
Drupal\flysystemView source
class FlysystemBridge extends FlysystemStreamWrapper implements StreamWrapperInterface {
  use StringTranslationTrait;
  /**
   * {@inheritdoc}
   */
  public static function getType() {
    return StreamWrapperInterface::WRITE_VISIBLE;
  }
  /**
   * {@inheritdoc}
   */
  public function getName() {
    $scheme = $this
      ->getProtocol();
    $name = (string) $this
      ->getFactory()
      ->getSettings($scheme)['name'];
    $default = $this
      ->t('Flysystem: @scheme', [
      '@scheme' => $scheme,
    ]);
    return $name !== '' ? $this
      ->t($name) : $default;
  }
  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    $scheme = $this
      ->getProtocol();
    $description = (string) $this
      ->getFactory()
      ->getSettings($scheme)['description'];
    $default = $this
      ->t('Flysystem: @scheme', [
      '@scheme' => $scheme,
    ]);
    return $description !== '' ? $this
      ->t($description) : $default;
  }
  /**
   * {@inheritdoc}
   */
  public function getUri() {
    return $this->uri;
  }
  /**
   * {@inheritdoc}
   */
  public function setUri($uri) {
    $this->uri = $uri;
  }
  /**
   * {@inheritdoc}
   */
  public function getExternalUrl() {
    return $this
      ->getFactory()
      ->getPlugin($this
      ->getProtocol())
      ->getExternalUrl($this->uri);
  }
  /**
   * {@inheritdoc}
   */
  public function realpath() {
    return FALSE;
  }
  /**
   * {@inheritdoc}
   */
  public function dirname($uri = NULL) {
    if (!isset($uri)) {
      $uri = $this->uri;
    }
    list($scheme, $target) = explode('://', $uri, 2);
    return $scheme . '://' . ltrim(Util::dirname($target), '\\/');
  }
  /**
   * Returns the filesystem for a given scheme.
   *
   * @param string $scheme
   *   The scheme.
   *
   * @return \League\Flysystem\FilesystemInterface
   *   The filesystem for the scheme.
   */
  protected function getFilesystemForScheme($scheme) {
    if (!isset(static::$filesystems[$scheme])) {
      static::$filesystems[$scheme] = $this
        ->getFactory()
        ->getFilesystem($scheme);
      static::$config[$scheme] = static::$defaultConfiguration;
      static::$config[$scheme]['permissions']['dir']['public'] = 0777;
      static::registerPlugins($scheme, static::$filesystems[$scheme]);
    }
    return static::$filesystems[$scheme];
  }
  /**
   * {@inheritdoc}
   */
  protected function getFilesystem() {
    if (!isset($this->filesystem)) {
      $this->filesystem = $this
        ->getFilesystemForScheme($this
        ->getProtocol());
    }
    return $this->filesystem;
  }
  /**
   * Returns the filesystem factory.
   *
   * @return \Drupal\flysystem\FlysystemFactory
   *   The Flysystem factory.
   */
  protected function getFactory() {
    return \Drupal::service('flysystem_factory');
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| FlysystemBridge:: | public | function | Gets the name of the directory from a given path. Overrides StreamWrapperInterface:: | |
| FlysystemBridge:: | public | function | Returns the description of the stream wrapper for use in the UI. Overrides StreamWrapperInterface:: | |
| FlysystemBridge:: | public | function | Returns a web accessible URL for the resource. Overrides StreamWrapperInterface:: | |
| FlysystemBridge:: | protected | function | Returns the filesystem factory. | |
| FlysystemBridge:: | protected | function | ||
| FlysystemBridge:: | protected | function | Returns the filesystem for a given scheme. | |
| FlysystemBridge:: | public | function | Returns the name of the stream wrapper for use in the UI. Overrides StreamWrapperInterface:: | |
| FlysystemBridge:: | public static | function | Returns the type of stream wrapper. Overrides StreamWrapperInterface:: | |
| FlysystemBridge:: | public | function | Returns the stream resource URI. Overrides StreamWrapperInterface:: | |
| FlysystemBridge:: | public | function | Returns canonical, absolute path of the resource. Overrides StreamWrapperInterface:: | |
| FlysystemBridge:: | public | function | Sets the absolute stream resource URI. Overrides StreamWrapperInterface:: | |
| PhpStreamWrapperInterface:: | public | function | 1 | |
| PhpStreamWrapperInterface:: | public | function | 1 | |
| PhpStreamWrapperInterface:: | public | function | 1 | |
| PhpStreamWrapperInterface:: | public | function | 1 | |
| PhpStreamWrapperInterface:: | public | function | 2 | |
| PhpStreamWrapperInterface:: | public | function | 2 | |
| PhpStreamWrapperInterface:: | public | function | 2 | |
| PhpStreamWrapperInterface:: | public | function | Retrieve the underlying stream resource. | 1 | 
| PhpStreamWrapperInterface:: | public | function | Closes stream. | 1 | 
| PhpStreamWrapperInterface:: | public | function | 1 | |
| PhpStreamWrapperInterface:: | public | function | 2 | |
| PhpStreamWrapperInterface:: | public | function | 2 | |
| PhpStreamWrapperInterface:: | public | function | Sets metadata on the stream. | 2 | 
| PhpStreamWrapperInterface:: | public | function | 2 | |
| PhpStreamWrapperInterface:: | public | function | 1 | |
| PhpStreamWrapperInterface:: | public | function | Seeks to specific location in a stream. | 1 | 
| PhpStreamWrapperInterface:: | public | function | Change stream options. | 1 | 
| PhpStreamWrapperInterface:: | public | function | 1 | |
| PhpStreamWrapperInterface:: | public | function | 1 | |
| PhpStreamWrapperInterface:: | public | function | Truncate stream. | 2 | 
| PhpStreamWrapperInterface:: | public | function | 2 | |
| PhpStreamWrapperInterface:: | public | function | 2 | |
| PhpStreamWrapperInterface:: | public | function | 1 | |
| StreamWrapperInterface:: | constant | A filter that matches all wrappers. | ||
| StreamWrapperInterface:: | constant | Defines the stream wrapper bit flag for a hidden file. | ||
| StreamWrapperInterface:: | constant | Refers to a local file system location. | ||
| StreamWrapperInterface:: | constant | Hidden, readable and writable using local files. | ||
| StreamWrapperInterface:: | constant | Visible, readable and writable using local files. | ||
| StreamWrapperInterface:: | constant | This is the default 'type' flag. This does not include StreamWrapperInterface::LOCAL, because PHP grants a greater trust level to local files (for example, they can be used in an "include" statement, regardless of the… | ||
| StreamWrapperInterface:: | constant | Wrapper is readable (almost always true). | ||
| StreamWrapperInterface:: | constant | Visible and read-only. | ||
| StreamWrapperInterface:: | constant | Exposed in the UI and potentially web accessible. | ||
| StreamWrapperInterface:: | constant | Wrapper is writable. | ||
| StreamWrapperInterface:: | constant | Visible, readable and writable. | ||
| StringTranslationTrait:: | protected | property | The string translation service. | 1 | 
| StringTranslationTrait:: | protected | function | Formats a string containing a count of items. | |
| StringTranslationTrait:: | protected | function | Returns the number of plurals supported by a given language. | |
| StringTranslationTrait:: | protected | function | Gets the string translation service. | |
| StringTranslationTrait:: | public | function | Sets the string translation service to use. | 2 | 
| StringTranslationTrait:: | protected | function | Translates a string to the current language or to a given language. | 
