Skip to content

Instantly share code, notes, and snippets.

@klaasvw
Created December 6, 2020 08:44
Show Gist options
  • Save klaasvw/588252082bd2a2f79fa5bff23e80617e to your computer and use it in GitHub Desktop.
Save klaasvw/588252082bd2a2f79fa5bff23e80617e to your computer and use it in GitHub Desktop.
Remove or strip the scheme from a file stream wrapper 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');
$target = $stream_wrapper_manager->getTarget($uri);
// $target = 'path/to/file.txt';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment