diff --git a/core/lib/Drupal/Core/StreamWrapper/ExtensionStreamBase.php b/core/lib/Drupal/Core/StreamWrapper/ExtensionStreamBase.php index 13cdf21..c54e3f6 100644 --- a/core/lib/Drupal/Core/StreamWrapper/ExtensionStreamBase.php +++ b/core/lib/Drupal/Core/StreamWrapper/ExtensionStreamBase.php @@ -44,17 +44,9 @@ public static function getType() { * * @return string * The extension name. - * - * @throws \InvalidArgumentException - * In case of a malformed uri. */ protected function getOwnerName() { $uri_parts = explode('://', $this->uri, 2); - if (count($uri_parts) === 1) { - // The delimiter ('://') was not found in $uri, malformed $uri passed. - throw new \InvalidArgumentException("Malformed uri parameter passed: {$this->uri}"); - } - // Remove the trailing filename from the path. $length = strpos($uri_parts[1], '/'); return ($length === FALSE) ? $uri_parts[1] : substr($uri_parts[1], 0, $length); diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php index 87c2ce2..fed91b0 100644 --- a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php @@ -18,34 +18,11 @@ * \Drupal\Core\StreamWrapper\LocalStream implementations need to implement at * least the getDirectoryPath() and getExternalUrl() methods. */ -abstract class LocalStream implements StreamWrapperInterface { +abstract class LocalStream extends StreamWrapperBase { use LocalStreamTrait; /** - * Stream context resource. - * - * @var resource - */ - public $context; - - /** - * A generic resource handle. - * - * @var resource - */ - public $handle = NULL; - - /** - * Instance URI (stream). - * - * A stream is referenced as "scheme://target". - * - * @var string - */ - protected $uri; - - /** * {@inheritdoc} */ public static function getType() { @@ -63,20 +40,6 @@ public static function getType() { /** * {@inheritdoc} */ - function setUri($uri) { - $this->uri = $uri; - } - - /** - * {@inheritdoc} - */ - function getUri() { - return $this->uri; - } - - /** - * {@inheritdoc} - */ public function realpath() { return $this->getLocalPath(); } diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalStreamTrait.php b/core/lib/Drupal/Core/StreamWrapper/LocalStreamTrait.php index 0fcc87e..871544a 100644 --- a/core/lib/Drupal/Core/StreamWrapper/LocalStreamTrait.php +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStreamTrait.php @@ -7,6 +7,9 @@ namespace Drupal\Core\StreamWrapper; +/** + * Provides common methods for local streams. + */ trait LocalStreamTrait { /** diff --git a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php index cc6da4b..c0ca884 100644 --- a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php @@ -17,43 +17,7 @@ * Drupal\Core\StreamWrapper\ReadOnlyStream implementations need to implement * all the read-related classes. */ -abstract class ReadOnlyStream implements StreamWrapperInterface { - /** - * Stream context resource. - * - * @var resource - */ - public $context; - - /** - * A generic resource handle. - * - * @var resource - */ - public $handle = NULL; - - /** - * Instance URI (stream). - * - * A stream is referenced as "scheme://target". - * - * @var string - */ - protected $uri; - - /** - * {@inheritdoc} - */ - function setUri($uri) { - $this->uri = $uri; - } - - /** - * {@inheritdoc} - */ - function getUri() { - return $this->uri; - } +abstract class ReadOnlyStream extends StreamWrapperBase { /** * Support for fopen(), file_get_contents(), etc. diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperBase.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperBase.php new file mode 100644 index 0000000..b18ee05 --- /dev/null +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperBase.php @@ -0,0 +1,56 @@ +uri}"); + } + $this->uri = $uri; + } + + /** + * {@inheritdoc} + */ + function getUri() { + return $this->uri; + } + +} diff --git a/core/modules/system/src/Tests/Theme/ThemeTest.php b/core/modules/system/src/Tests/Theme/ThemeTest.php index 3d8b784..497c657 100644 --- a/core/modules/system/src/Tests/Theme/ThemeTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeTest.php @@ -265,7 +265,7 @@ function testClassLoading() { */ public function testFindThemeTemplates() { $registry = $this->container->get('theme.registry')->get(); - $templates = drupal_find_theme_templates($registry, '.html.twig', drupal_get_path('theme', 'test_theme')); + $templates = drupal_find_theme_templates($registry, '.html.twig', 'theme://test_theme'); $this->assertEqual($templates['node__1']['template'], 'node--1', 'Template node--1.tpl.twig was found in test_theme.'); } diff --git a/core/modules/system/tests/src/Kernel/File/ExtensionStreamTest.php b/core/modules/system/tests/src/Kernel/File/ExtensionStreamTest.php index 565c6ef..f31d581 100644 --- a/core/modules/system/tests/src/Kernel/File/ExtensionStreamTest.php +++ b/core/modules/system/tests/src/Kernel/File/ExtensionStreamTest.php @@ -109,7 +109,7 @@ public function providerInvalidUris() { * Test the extension stream wrapper methods. * * @param string $uri - * The uri to be tested, + * The uri to be tested. * @param string|\InvalidArgumentException $dirname * The expectation for dirname() method. * @param string|\InvalidArgumentException $realpath