diff --git a/core/core.services.yml b/core/core.services.yml index 8dc5a92..109f274 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1287,10 +1287,6 @@ services: class: Drupal\Core\StreamWrapper\ProfileStream tags: - { name: stream_wrapper, scheme: profile } - stream_wrapper.library: - class: Drupal\Core\StreamWrapper\LibraryStream - tags: - - { name: stream_wrapper, scheme: library } kernel_destruct_subscriber: class: Drupal\Core\EventSubscriber\KernelDestructionSubscriber tags: diff --git a/core/lib/Drupal/Core/Extension/LibraryDiscovery.php b/core/lib/Drupal/Core/Extension/LibraryDiscovery.php deleted file mode 100644 index cdfb1ce..0000000 --- a/core/lib/Drupal/Core/Extension/LibraryDiscovery.php +++ /dev/null @@ -1,97 +0,0 @@ -root). - $dir_prefix = ($dir == '' ? '' : "$dir/") . self::LIBRARIES_DIRECTORY . '/'; - $absolute_dir = ($dir == '' ? $this->root : $this->root . "/$dir"); - $absolute_dir .= '/' . self::LIBRARIES_DIRECTORY; - - if (!is_dir($absolute_dir)) { - return $files; - } - // Use Unix paths regardless of platform, skip dot directories, follow - // symlinks (to allow extensions to be linked from elsewhere), and return - // the RecursiveDirectoryIterator instance to have access to getSubPath(), - // since SplFileInfo does not support relative paths. - $flags = \FilesystemIterator::UNIX_PATHS; - $flags |= \FilesystemIterator::SKIP_DOTS; - $flags |= \FilesystemIterator::FOLLOW_SYMLINKS; - $flags |= \FilesystemIterator::CURRENT_AS_SELF; - $directory_iterator = new \RecursiveDirectoryIterator($absolute_dir, $flags); - - /** - * @var string $key - * @var \RecursiveDirectoryIterator $fileinfo - */ - foreach ($directory_iterator as $key => $fileinfo) { - if ($this->fileCache && $cached_extension = $this->fileCache->get($fileinfo->getPathname())) { - $files[$cached_extension->getType()][$key] = $cached_extension; - continue; - } - - if (!$fileinfo->isDir()) { - continue; - } - - $type = self::EXTENSION_TYPE; - $name = $fileinfo->getBasename(); - $pathname = $dir_prefix . $fileinfo->getSubPathname(); - - $extension = new Extension($this->root, $type, $pathname); - - // Track the originating directory for sorting purposes. - $extension->subpath = self::LIBRARIES_DIRECTORY . '/' . $fileinfo->getFilename(); - $extension->origin = $dir; - - $files[$type][$key] = $extension; - - if ($this->fileCache) { - $this->fileCache->set($fileinfo->getPathname(), $extension); - } - } - - return $files; - } - - /** - * {@inheritdoc} - */ - public function scan($type, $include_tests = NULL) { - return parent::scan(self::EXTENSION_TYPE); - } - -} diff --git a/core/lib/Drupal/Core/StreamWrapper/LibraryStream.php b/core/lib/Drupal/Core/StreamWrapper/LibraryStream.php deleted file mode 100644 index ee6294d..0000000 --- a/core/lib/Drupal/Core/StreamWrapper/LibraryStream.php +++ /dev/null @@ -1,84 +0,0 @@ -getDrupalRoot()); - $files = $library_discovery->scan($name); - if (!isset($files[$name])) { - throw new \RuntimeException("Library $name does not exist"); - } - - return $name; - } - - /** - * {@inheritdoc} - */ - protected function getDirectoryPath() { - $name = parent::getOwnerName(); - $library_discovery = new LibraryDiscovery($this->getDrupalRoot()); - /** @var $files \Drupal\Core\Extension\Extension[] */ - $files = $library_discovery->scan($name); - $name = $this->getOwnerName(); - return $files[$name]->getPathname(); - } - - /** - * {@inheritdoc} - */ - public function getName() { - return $this->t('Library files'); - } - - /** - * {@inheritdoc} - */ - public function getDescription() { - return $this->t('Local files stored under the libraries directory.'); - } - - /** - * Return the path to the Drupal root. - * - * Since stream wrappers don't allow us to pass in __construct() parameters, - * we have to fall back to \Drupal. - * - * @return string - */ - protected function getDrupalRoot() { - if (!isset($this->drupalRoot)) { - $this->drupalRoot = \Drupal::root(); - } - return $this->drupalRoot; - } - - /** - * Set the path to the Drupal root. - * - * @param string $drupalRoot - * The absolute path to the root of the Drupal installation. - */ - public function setDrupalRoot($drupalRoot) { - $this->drupalRoot = $drupalRoot; - } - -} diff --git a/core/modules/system/tests/src/Kernel/File/ExtensionStreamTest.php b/core/modules/system/tests/src/Kernel/File/ExtensionStreamTest.php index 27d5a41..52d064f 100644 --- a/core/modules/system/tests/src/Kernel/File/ExtensionStreamTest.php +++ b/core/modules/system/tests/src/Kernel/File/ExtensionStreamTest.php @@ -32,14 +32,7 @@ class ExtensionStreamTest extends KernelTestBase { * * @var string[] */ - public static $modules = ['system']; - - /** - * The path to the stub library for testing the library wrapper. - * - * @var string - */ - protected $stubLibraryPath; + public static $modules = ['file_module_test', 'system']; /** * {@inheritdoc} @@ -53,7 +46,7 @@ public function setUp() { /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */ $stream_wrapper_manager = $this->container->get('stream_wrapper_manager'); // Get stream wrapper instances. - foreach (['module', 'theme', 'profile', 'library'] as $scheme) { + foreach (['module', 'theme', 'profile'] as $scheme) { $this->streamWrappers[$scheme] = $stream_wrapper_manager->getViaScheme($scheme); } @@ -73,21 +66,6 @@ public function setUp() { $theme_installer = $this->container->get('theme_installer'); // Install Bartik and Seven themes. $theme_installer->install(['bartik', 'seven']); - - // Create a stub library for testing. - $this->stubLibraryPath = \Drupal::service('site.path') . '/libraries/extension-stream-test'; - $f = new Filesystem(); - $f->mkdir([$this->stubLibraryPath, $this->stubLibraryPath . '/subdirectory']); - $f->touch([$this->stubLibraryPath . '/empty', $this->stubLibraryPath . '/subdirectory/empty']); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() { - parent::tearDown(); - $f = new Filesystem(); - $f->remove($this->stubLibraryPath); } /** @@ -217,16 +195,16 @@ public function providerStreamWrapperMethods() { 'core/modules/system/css/system.admin.css', ], [ - 'module://file_test/file_test.dummy.inc', - 'module://file_test', - '/core/modules/file/tests/file_test/file_test.dummy.inc', - 'core/modules/file/tests/file_test/file_test.dummy.inc', + 'module://file_module_test/file_module_test.dummy.inc', + 'module://file_module_test', + '/core/modules/file/tests/file_module_test/file_module_test.dummy.inc', + 'core/modules/file/tests/file_module_test/file_module_test.dummy.inc', ], [ - 'module://file_test/src/file_test.dummy.inc', - 'module://file_test/src', - '/core/modules/file/tests/file_test/src/file_test.dummy.inc', - 'core/modules/file/tests/file_test/src/file_test.dummy.inc', + 'module://file_module_test/src/file_module_test.dummy.inc', + 'module://file_module_test/src', + '/core/modules/file/tests/file_module_test/src/file_module_test.dummy.inc', + 'core/modules/file/tests/file_module_test/src/file_module_test.dummy.inc', ], [ 'module://ckeditor/ckeditor.info.yml', @@ -296,37 +274,6 @@ public function providerStreamWrapperMethods() { '/core/profiles/minimal/minimal.info.yml', 'core/profiles/minimal/minimal.info.yml', ], - // Cases for library:// stream wrapper. - [ - 'library://extension-stream-test', - 'library://extension-stream-test', - '/libraries/extension-stream-test', - 'libraries/extension-stream-test', - ], - [ - 'library://extension-stream-test/empty', - 'library://extension-stream-test', - '/libraries/extension-stream-test/empty', - 'libraries/extension-stream-test/empty', - ], - [ - 'library://extension-stream-test/subdirectory/empty', - 'library://extension-stream-test/subdirectory', - '/libraries/extension-stream-test/subdirectory/empty', - 'libraries/extension-stream-test/subdirectory/empty', - ], - [ - 'library://does-not-exist', - new \RuntimeException('Library does-not-exist does not exist'), - new \RuntimeException('Library does-not-exist does not exist'), - new \RuntimeException('Library does-not-exist does not exist'), - ], - [ - 'library://does-not-exist/does-not-exist.js', - new \RuntimeException('Library does-not-exist does not exist'), - new \RuntimeException('Library does-not-exist does not exist'), - new \RuntimeException('Library does-not-exist does not exist'), - ], ]; }