You are here

trait SchemeExtensionTrait in Flysystem 8

Same name and namespace in other branches
  1. 3.x src/Asset/SchemeExtensionTrait.php \Drupal\flysystem\Asset\SchemeExtensionTrait
  2. 2.0.x src/Asset/SchemeExtensionTrait.php \Drupal\flysystem\Asset\SchemeExtensionTrait
  3. 3.0.x src/Asset/SchemeExtensionTrait.php \Drupal\flysystem\Asset\SchemeExtensionTrait

Flysystem dependency injection container.

Hierarchy

2 files declare their use of SchemeExtensionTrait
FlysystemServiceProvider.php in src/FlysystemServiceProvider.php
SchemeExtensionTraitTest.php in tests/src/Unit/Asset/SchemeExtensionTraitTest.php

File

src/Asset/SchemeExtensionTrait.php, line 10

Namespace

Drupal\flysystem\Asset
View source
trait SchemeExtensionTrait {

  /**
   * Returns the scheme that should serve an extension.
   *
   * @param string $extension
   *   The extension.
   *
   * @return string
   *   The scheme that should serve the extension.
   */
  public function getSchemeForExtension($extension) {
    $extension_scheme = 'public';
    foreach (Settings::get('flysystem', []) as $scheme => $configuration) {
      if (!empty($configuration['serve_' . $extension]) && !empty($configuration['driver'])) {

        // Don't break, the last configured one will win.
        $extension_scheme = $scheme;
      }
    }
    return $extension_scheme;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SchemeExtensionTrait::getSchemeForExtension public function Returns the scheme that should serve an extension.