diff --git a/core/includes/file.inc b/core/includes/file.inc index 066f0bd..df4b742 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -162,7 +162,7 @@ function file_uri_scheme($uri) { * or FALSE if the scheme does not have a registered handler. */ function file_stream_wrapper_valid_scheme($scheme) { - return $scheme && class_exists(file_stream_wrapper_get_class($scheme)); + return $scheme && class_exists(\Drupal::service('stream_wrapper_manager')->getClass($scheme)); } @@ -344,7 +344,7 @@ function file_create_url($uri) { } else { // Attempt to return an external URL using the appropriate wrapper. - if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) { + if ($wrapper = \Drupal::service('stream_wrapper_manager')->getViaUri($uri)) { return $wrapper->getExternalUrl(); } else { @@ -1249,7 +1249,7 @@ function drupal_realpath($uri) { // If this URI is a stream, pass it off to the appropriate stream wrapper. // Otherwise, attempt PHP's realpath. This allows use of drupal_realpath even // for unmanaged files outside of the stream wrapper interface. - if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) { + if ($wrapper = \Drupal::service('stream_wrapper_manager')->getViaUri($uri)) { return $wrapper->realpath(); } @@ -1279,7 +1279,7 @@ function drupal_dirname($uri) { $scheme = file_uri_scheme($uri); if (file_stream_wrapper_valid_scheme($scheme)) { - return file_stream_wrapper_get_instance_by_scheme($scheme)->dirname($uri); + return \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme)->dirname($uri); } else { return dirname($uri); @@ -1472,7 +1472,7 @@ function drupal_tempnam($directory, $prefix) { $scheme = file_uri_scheme($directory); if (file_stream_wrapper_valid_scheme($scheme)) { - $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme); + $wrapper = \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme); if ($filename = tempnam($wrapper->getDirectoryPath(), $prefix)) { return $scheme . '://' . drupal_basename($filename); diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index dba7a94..4aaf301 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -269,12 +269,11 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // Record the fact that it was installed. $modules_installed[] = $module; - // file_get_stream_wrappers() needs to re-register Drupal's stream - // wrappers in case a module-provided stream wrapper is used later in - // the same request. In particular, this happens when installing Drupal - // via Drush, as the 'translations' stream wrapper is provided by - // Interface Translation module and is later used to import - // translations. + // Drupal's stream wrappers needs to be re-registered in case a + // module-provided stream wrapper is used later in the same request. In + // particular, this happens when installing Drupal via Drush, as the + // 'translations' stream wrapper is provided by Interface Translation + // module and is later used to import translations. \Drupal::service('stream_wrapper_manager')->register(); // Update the theme registry to include it. diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php index 101980d..78fb3d5 100644 --- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php @@ -13,7 +13,6 @@ /** * Provides a StreamWrapper manager. * - * @see file_get_stream_wrappers() * @see \Drupal\Core\StreamWrapper\StreamWrapperInterface */ class StreamWrapperManager extends ContainerAware { @@ -69,7 +68,8 @@ class StreamWrapperManager extends ContainerAware { * returns only stream wrappers that use local file storage: * * @code - * $local_stream_wrappers = file_get_stream_wrappers(StreamWrapperInterface::LOCAL); + * $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager'); + * $local_stream_wrappers = $stream_wrapper_manager->getWrappers(StreamWrapperInterface::LOCAL); * @endcode * * The $filter parameter can only filter to types containing a particular @@ -79,7 +79,11 @@ class StreamWrapperManager extends ContainerAware { * array_diff_key() function can be used to help with this. For example, this * returns only stream wrappers that do not use local file storage: * @code - * $remote_stream_wrappers = array_diff_key(file_get_stream_wrappers(StreamWrapperInterface::ALL), file_get_stream_wrappers(StreamWrapperInterface::LOCAL)); + * $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager'); + * $remote_stream_wrappers = array_diff_key( + * $stream_wrapper_manager->getWrappers(StreamWrapperInterface::ALL), + * $stream_wrapper_manager->getWrappers(StreamWrapperInterface::LOCAL) + * ); * @endcode * * @param int $filter diff --git a/core/lib/Drupal/Core/Updater/Updater.php b/core/lib/Drupal/Core/Updater/Updater.php index bbaecfb..a2d31c4 100644 --- a/core/lib/Drupal/Core/Updater/Updater.php +++ b/core/lib/Drupal/Core/Updater/Updater.php @@ -343,7 +343,7 @@ public function makeBackup(FileTransferInterface $filetransfer, $from, $to) { * Returns the full path to a directory where backups should be written. */ public function getBackupDir() { - return file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath(); + return \Drupal::service('stream_wrapper_manager')->getViaScheme('temporary')->getDirectoryPath(); } /** diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php index 1aece59..4e8dd5d 100644 --- a/core/modules/file/src/Tests/DownloadTest.php +++ b/core/modules/file/src/Tests/DownloadTest.php @@ -30,7 +30,7 @@ function testPublicFileTransfer() { $url = file_create_url($file->getFileUri()); // URLs can't contain characters outside the ASCII set so $filename has to be // encoded. - $filename = $GLOBALS['base_url'] . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . rawurlencode($file->getFilename()); + $filename = $GLOBALS['base_url'] . '/' . \Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath() . '/' . rawurlencode($file->getFilename()); $this->assertEqual($filename, $url, 'Correctly generated a URL for a created file.'); $this->drupalHead($url); $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the created file.'); @@ -123,7 +123,7 @@ function testFileCreateUrl() { $clean_urls = $clean_url_setting == 'clean'; $request = $this->prepareRequestForGenerator($clean_urls); $base_path = $request->getSchemeAndHttpHost() . $request->getBasePath(); - $this->checkUrl('public', '', $basename, $base_path . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . $basename_encoded); + $this->checkUrl('public', '', $basename, $base_path . '/' . \Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath() . '/' . $basename_encoded); $this->checkUrl('private', '', $basename, $base_path . '/' . $script_path . 'system/files/' . $basename_encoded); } $this->assertEqual(file_create_url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Generated URL matches expected URL.')); diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index 8c12c56..86291f6 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -217,7 +217,7 @@ function file_test_file_url_alter(&$uri) { } // Public created files. else { - $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme); + $wrapper = \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme); $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri); } @@ -247,7 +247,7 @@ function file_test_file_url_alter(&$uri) { } // Public created files. else { - $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme); + $wrapper = \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme); $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri); } @@ -270,7 +270,7 @@ function file_test_file_url_alter(&$uri) { } // Public created files. else { - $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme); + $wrapper = \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme); $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri); } diff --git a/core/modules/image/image.services.yml b/core/modules/image/image.services.yml index 7f1f985..5effaf9 100644 --- a/core/modules/image/image.services.yml +++ b/core/modules/image/image.services.yml @@ -1,6 +1,7 @@ services: path_processor.image_styles: class: Drupal\image\PathProcessor\PathProcessorImageStyles + arguments: ['@stream_wrapper_manager'] tags: - { name: path_processor_inbound, priority: 300 } plugin.manager.image.effect: diff --git a/core/modules/image/src/Entity/ImageStyle.php b/core/modules/image/src/Entity/ImageStyle.php index cf9c861..0013251 100644 --- a/core/modules/image/src/Entity/ImageStyle.php +++ b/core/modules/image/src/Entity/ImageStyle.php @@ -222,7 +222,7 @@ public function buildUrl($path, $clean_urls = NULL) { // that it is included. Once the file exists it's fine to fall back to the // actual file path, this avoids bootstrapping PHP once the files are built. if ($clean_urls === FALSE && file_uri_scheme($uri) == 'public' && !file_exists($uri)) { - $directory_path = file_stream_wrapper_get_instance_by_uri($uri)->getDirectoryPath(); + $directory_path = \Drupal::service('stream_wrapper_manager')->getViaUri($uri)->getDirectoryPath(); return _url($directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query)); } diff --git a/core/modules/image/src/PathProcessor/PathProcessorImageStyles.php b/core/modules/image/src/PathProcessor/PathProcessorImageStyles.php index 4418476..6294d25 100644 --- a/core/modules/image/src/PathProcessor/PathProcessorImageStyles.php +++ b/core/modules/image/src/PathProcessor/PathProcessorImageStyles.php @@ -8,6 +8,7 @@ namespace Drupal\image\PathProcessor; use Drupal\Core\PathProcessor\InboundPathProcessorInterface; +use Drupal\Core\StreamWrapper\StreamWrapperManager; use Symfony\Component\HttpFoundation\Request; /** @@ -28,10 +29,27 @@ class PathProcessorImageStyles implements InboundPathProcessorInterface { /** + * The stream wrapper manager service. + * + * @var \Drupal\Core\StreamWrapper\StreamWrapperManager + */ + protected $streamWrapperManager; + + /** + * Constructs a new PathProcessorImageStyles object. + * + * @param \Drupal\Core\StreamWrapper\StreamWrapperManager $stream_wrapper_manager + * The stream wrapper manager service. + */ + public function __construct(StreamWrapperManager $stream_wrapper_manager) { + $this->streamWrapperManager = $stream_wrapper_manager; + } + + /** * {@inheritdoc} */ public function processInbound($path, Request $request) { - $directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(); + $directory_path = $this->streamWrapperManager->getViaScheme('public')->getDirectoryPath(); if (strpos($path, $directory_path . '/styles/') === 0) { $path_prefix = $directory_path . '/styles/'; } diff --git a/core/modules/image/src/Routing/ImageStyleRoutes.php b/core/modules/image/src/Routing/ImageStyleRoutes.php index 39b2379..e8d52da 100644 --- a/core/modules/image/src/Routing/ImageStyleRoutes.php +++ b/core/modules/image/src/Routing/ImageStyleRoutes.php @@ -7,12 +7,41 @@ namespace Drupal\image\Routing; +use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\StreamWrapper\StreamWrapperManager; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Route; /** * Defines a route subscriber to register a url for serving image styles. */ -class ImageStyleRoutes { +class ImageStyleRoutes implements ContainerInjectionInterface { + + /** + * The stream wrapper manager service. + * + * @var \Drupal\Core\StreamWrapper\StreamWrapperManager + */ + protected $streamWrapperManager; + + /** + * Constructs a new PathProcessorImageStyles object. + * + * @param \Drupal\Core\StreamWrapper\StreamWrapperManager $stream_wrapper_manager + * The stream wrapper manager service. + */ + public function __construct(StreamWrapperManager $stream_wrapper_manager) { + $this->streamWrapperManager = $stream_wrapper_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('stream_wrapper_manager') + ); + } /** * Returns an array of route objects. @@ -26,7 +55,7 @@ public function routes() { // disabled image derivatives will always be served through the menu system. // If clean URLs are enabled and the image derivative already exists, PHP // will be bypassed. - $directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(); + $directory_path = $this->streamWrapperManager->getViaScheme('public')->getDirectoryPath(); $routes['image.style_public'] = new Route( '/' . $directory_path . '/styles/{image_style}/{scheme}', diff --git a/core/modules/system/file.api.php b/core/modules/system/file.api.php index 21b62b3..f5aa528 100644 --- a/core/modules/system/file.api.php +++ b/core/modules/system/file.api.php @@ -80,7 +80,7 @@ function hook_file_url_alter(&$uri) { } // Public created files. else { - $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme); + $wrapper = \Drupal::service('stream_wrapper_manager')->getViaScheme($scheme); $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri); } diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php index d16330f..1b01f3f 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php @@ -9,8 +9,12 @@ use Drupal\Component\Utility\Color; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\ImageToolkit\ImageToolkitBase; +use Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface; +use Drupal\Core\StreamWrapper\StreamWrapperManager; +use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\StreamWrapper\StreamWrapperInterface; @@ -54,6 +58,36 @@ class GDToolkit extends ImageToolkitBase { protected $preLoadInfo = NULL; /** + * The StreamWrapper manager. + * + * @var \Drupal\Core\StreamWrapper\StreamWrapperManager + */ + protected $streamWrapperManager; + + /** + * Constructs a TestToolkit object. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param array $plugin_definition + * The plugin implementation definition. + * @param \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface $operation_manager + * The toolkit operation manager. + * @param \Psr\Log\LoggerInterface $logger + * A logger instance. + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * The config factory. + * @param \Drupal\Core\StreamWrapper\StreamWrapperManager $stream_wrapper_manager + * The StreamWrapper manager. + */ + public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger, ConfigFactoryInterface $config_factory, StreamWrapperManager $stream_wrapper_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $operation_manager, $logger, $config_factory); + $this->streamWrapperManager = $stream_wrapper_manager; + } + + /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { @@ -63,7 +97,8 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_definition, $container->get('image.toolkit.operation.manager'), $container->get('logger.channel.image'), - $container->get('config.factory') + $container->get('config.factory'), + $container->get('stream_wrapper_manager') ); } @@ -172,7 +207,7 @@ public function save($destination) { // Work around lack of stream wrapper support in imagejpeg() and imagepng(). if ($scheme && file_stream_wrapper_valid_scheme($scheme)) { // If destination is not local, save image to temporary local file. - $local_wrappers = file_get_stream_wrappers(StreamWrapperInterface::LOCAL); + $local_wrappers = $this->streamWrapperManager->getWrappers(StreamWrapperInterface::LOCAL); if (!isset($local_wrappers[$scheme])) { $permanent_destination = $destination; $destination = drupal_tempnam('temporary://', 'gd_'); diff --git a/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php index 130ffd2..95189af 100644 --- a/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php +++ b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Extension; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Drupal\simpletest\KernelTestBase; use \Drupal\Core\Extension\ModuleUninstallValidatorException; @@ -279,14 +280,14 @@ function testModuleMetaData() { public function testModuleStreamWrappers() { // file_test.module provides (among others) a 'dummy' stream wrapper. // Verify that it is not registered yet to prevent false positives. - $stream_wrappers = file_get_stream_wrappers(); + $stream_wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers(); $this->assertFalse(isset($stream_wrappers['dummy'])); $this->moduleInstaller()->install(['file_test']); // Verify that the stream wrapper is available even without calling - // file_get_stream_wrappers() again. If the stream wrapper is not available - // file_exists() will raise a notice. + // \Drupal::service('stream_wrapper_manager')->getWrappers() again. + // If the stream wrapper is not available file_exists() will raise a notice. file_exists('dummy://'); - $stream_wrappers = file_get_stream_wrappers(); + $stream_wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers(); $this->assertTrue(isset($stream_wrappers['dummy'])); } diff --git a/core/modules/system/src/Tests/File/ReadOnlyStreamWrapperTest.php b/core/modules/system/src/Tests/File/ReadOnlyStreamWrapperTest.php index 242a378..9e8bb35 100644 --- a/core/modules/system/src/Tests/File/ReadOnlyStreamWrapperTest.php +++ b/core/modules/system/src/Tests/File/ReadOnlyStreamWrapperTest.php @@ -39,7 +39,7 @@ function testReadOnlyBehavior() { // Generate a read-only stream wrapper instance $uri = $this->scheme . '://' . $filename; - file_stream_wrapper_get_instance_by_scheme($this->scheme); + \Drupal::service('stream_wrapper_manager')->getViaScheme($this->scheme); // Attempt to open a file in read/write mode $handle = @fopen($uri, 'r+'); diff --git a/core/modules/system/src/Tests/File/StreamWrapperTest.php b/core/modules/system/src/Tests/File/StreamWrapperTest.php index fb3c805..b13c4c6 100644 --- a/core/modules/system/src/Tests/File/StreamWrapperTest.php +++ b/core/modules/system/src/Tests/File/StreamWrapperTest.php @@ -56,19 +56,19 @@ function setUp() { */ function testGetClassName() { // Check the dummy scheme. - $this->assertEqual($this->classname, file_stream_wrapper_get_class($this->scheme), 'Got correct class name for dummy scheme.'); + $this->assertEqual($this->classname, \Drupal::service('stream_wrapper_manager')->getClass($this->scheme), 'Got correct class name for dummy scheme.'); // Check core's scheme. - $this->assertEqual('Drupal\Core\StreamWrapper\PublicStream', file_stream_wrapper_get_class('public'), 'Got correct class name for public scheme.'); + $this->assertEqual('Drupal\Core\StreamWrapper\PublicStream', \Drupal::service('stream_wrapper_manager')->getClass('public'), 'Got correct class name for public scheme.'); } /** - * Test the file_stream_wrapper_get_instance_by_scheme() function. + * Test the getViaScheme() function. */ function testGetInstanceByScheme() { - $instance = file_stream_wrapper_get_instance_by_scheme($this->scheme); + $instance = \Drupal::service('stream_wrapper_manager')->getViaScheme($this->scheme); $this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy scheme.'); - $instance = file_stream_wrapper_get_instance_by_scheme('public'); + $instance = \Drupal::service('stream_wrapper_manager')->getViaScheme('public'); $this->assertEqual('Drupal\Core\StreamWrapper\PublicStream', get_class($instance), 'Got correct class type for public scheme.'); } @@ -78,10 +78,10 @@ function testGetInstanceByScheme() { function testUriFunctions() { $config = $this->config('system.file'); - $instance = file_stream_wrapper_get_instance_by_uri($this->scheme . '://foo'); + $instance = \Drupal::service('stream_wrapper_manager')->getViaUri($this->scheme . '://foo'); $this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.'); - $instance = file_stream_wrapper_get_instance_by_uri('public://foo'); + $instance = \Drupal::service('stream_wrapper_manager')->getViaUri('public://foo'); $this->assertEqual('Drupal\Core\StreamWrapper\PublicStream', get_class($instance), 'Got correct class type for public URI.'); // Test file_uri_target(). @@ -94,8 +94,8 @@ function testUriFunctions() { // Test file_build_uri() and // Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath(). $this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.'); - $this->assertEqual(file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.'); - $this->assertEqual(file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.'); + $this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.'); + $this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.'); $config->set('default_scheme', 'private')->save(); $this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.'); diff --git a/core/modules/system/src/Tests/File/UrlRewritingTest.php b/core/modules/system/src/Tests/File/UrlRewritingTest.php index aa0d3d2..5fa4578 100644 --- a/core/modules/system/src/Tests/File/UrlRewritingTest.php +++ b/core/modules/system/src/Tests/File/UrlRewritingTest.php @@ -80,7 +80,7 @@ function testPublicManagedFileURL() { \Drupal::state()->set('file_test.hook_file_url_alter', 'cdn'); $uri = $this->createUri(); $url = file_create_url($uri); - $public_directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(); + $public_directory_path = \Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath(); $this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a CDN URL for a created file.'); // Test alteration of file URLs to use root-relative URLs. @@ -116,7 +116,7 @@ function testRelativeFileURL() { // Managed file. $uri = $this->createUri(); $url = file_create_url($uri); - $public_directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(); + $public_directory_path = \Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath(); $this->assertIdentical(base_path() . $public_directory_path . '/' . rawurlencode(drupal_basename($uri)), file_url_transform_relative($url)); } diff --git a/core/modules/system/src/Tests/Session/SessionTest.php b/core/modules/system/src/Tests/Session/SessionTest.php index bbe23f6..16824fa 100644 --- a/core/modules/system/src/Tests/Session/SessionTest.php +++ b/core/modules/system/src/Tests/Session/SessionTest.php @@ -273,7 +273,7 @@ function sessionReset($uid = 0) { $this->loggedInUser = FALSE; // Change cookie file for user. - $this->cookieFile = file_stream_wrapper_get_instance_by_scheme('temporary')->getDirectoryPath() . '/cookie.' . $uid . '.txt'; + $this->cookieFile = \Drupal::service('stream_wrapper_manager')->getViaScheme('temporary')->getDirectoryPath() . '/cookie.' . $uid . '.txt'; $this->additionalCurlOptions[CURLOPT_COOKIEFILE] = $this->cookieFile; $this->additionalCurlOptions[CURLOPT_COOKIESESSION] = TRUE; $this->drupalGet('session-test/get');