Skip to content

Instantly share code, notes, and snippets.

@klaasvw
Created December 6, 2020 08:46
Show Gist options
  • Save klaasvw/c3f51e496088d3135180566a5f80f594 to your computer and use it in GitHub Desktop.
Save klaasvw/c3f51e496088d3135180566a5f80f594 to your computer and use it in GitHub Desktop.
Get scheme from URI in Drupal 9
<?php
$uri = 'public://path/to/file.txt';
/** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
$stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
$scheme = $stream_wrapper_manager->getScheme($uri);
// $scheme = 'public';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment