function StreamWrapperManager::getScheme

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php \Drupal\Core\StreamWrapper\StreamWrapperManager::getScheme()
  2. 10 core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php \Drupal\Core\StreamWrapper\StreamWrapperManager::getScheme()
  3. 11.x core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php \Drupal\Core\StreamWrapper\StreamWrapperManager::getScheme()

Returns the scheme of a URI (e.g. a stream).

Parameters

string $uri: A stream, referenced as "scheme://target" or "data:target".

Return value

string|bool A string containing the name of the scheme, or FALSE if none. For example, the URI "public://example.txt" would return "public".

Overrides StreamWrapperManagerInterface::getScheme

12 calls to StreamWrapperManager::getScheme()
CssOptimizer::loadFile in core/lib/Drupal/Core/Asset/CssOptimizer.php
Loads the stylesheet and resolves all @import commands.
FileSystem::dirname in core/lib/Drupal/Core/File/FileSystem.php
Gets the name of the directory from a given path.
FileSystem::mkdir in core/lib/Drupal/Core/File/FileSystem.php
Creates a directory, optionally creating missing components in the path.
FileSystem::tempnam in core/lib/Drupal/Core/File/FileSystem.php
Creates a file with a unique filename in the specified directory.
FileUrlGenerator::doGenerateString in core/lib/Drupal/Core/File/FileUrlGenerator.php
Creates an absolute web-accessible URL string.

... See full list

File

core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php, line 286

Class

StreamWrapperManager
Provides a StreamWrapper manager.

Namespace

Drupal\Core\StreamWrapper

Code

public static function getScheme($uri) {
  if (preg_match('/^([\\w\\-]+):\\/\\/|^(data):/', $uri, $matches)) {
    // The scheme will always be the last element in the matches array.
    return array_pop($matches);
  }
  return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.