You are here

abstract class FlysystemPluginBase in Flysystem 7

Base class for plugins.

Hierarchy

Expanded class hierarchy of FlysystemPluginBase

3 files declare their use of FlysystemPluginBase
Ftp.php in src/Flysystem/Ftp.php
Contains \Drupal\flysystem\Flysystem\Ftp.
Local.php in src/Flysystem/Local.php
Contains \Drupal\flysystem\Flysystem\Local.
Missing.php in src/Flysystem/Missing.php
Contains \Drupal\flysystem\Flysystem\Missing.

File

src/Plugin/FlysystemPluginBase.php, line 15
Contains FlysystemPluginBase.

Namespace

Drupal\flysystem\Plugin
View source
abstract class FlysystemPluginBase implements FlysystemPluginInterface {

  /**
   * {@inheritdoc}
   */
  public static function create(array $configuration) {
    return new static($configuration);
  }

  /**
   * {@inheritdoc}
   */
  public function getExternalUrl($uri) {
    $path = str_replace('\\', '/', $this
      ->getTarget($uri));
    return url('_flysystem/' . $this
      ->getScheme($uri) . '/' . $path, array(
      'absolute' => TRUE,
    ));
  }

  /**
   * Returns the target file path of a URI.
   *
   * @param string $uri
   *   The URI.
   *
   * @return string
   *   The file path of the URI.
   */
  protected function getTarget($uri) {
    return Util::normalizePath(substr($uri, strpos($uri, '://') + 3));
  }

  /**
   * Returns the scheme from the internal URI.
   *
   * @param string $uri
   *   The URI.
   *
   * @return string
   *   The scheme.
   */
  protected function getScheme($uri) {
    return substr($uri, 0, strpos($uri, '://'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlysystemPluginBase::create public static function Creates a new plugin instance. Overrides FlysystemPluginInterface::create 1
FlysystemPluginBase::getExternalUrl public function Returns a web accessible URL for the resource. Overrides FlysystemPluginInterface::getExternalUrl 2
FlysystemPluginBase::getScheme protected function Returns the scheme from the internal URI.
FlysystemPluginBase::getTarget protected function Returns the target file path of a URI.
FlysystemPluginInterface::getAdapter public function Returns the Flysystem adapter 3