diff --git a/core/core.services.yml b/core/core.services.yml index e1514b3..c339ba1 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -580,6 +580,10 @@ services: class: Drupal\Core\StreamWrapper\PublicStream tags: - { name: stream_wrapper, scheme: public } + stream_wrapper.temporary: + class: Drupal\Core\StreamWrapper\TemporaryStream + tags: + - { name: stream_wrapper, scheme: temporary } kernel_destruct_subscriber: class: Drupal\Core\EventSubscriber\KernelDestructionSubscriber tags: diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 0259cec..72ad9e1 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -423,6 +423,12 @@ function install_begin_request(&$install_state) { $container ->register('module_handler', 'Drupal\Core\Extension\ModuleHandler'); + // Register the stream wrapper manager. + $container + ->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager') + ->addArgument(new Reference('module_handler')) + ->addMethodCall('setContainer', array($container)); + // Register the Guzzle HTTP client for fetching translation files from a // remote translation server such as localization.drupal.org. $container->register('http_default_client', 'Guzzle\Http\Client') diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php index 9992e1e..cbba989 100644 --- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php @@ -66,20 +66,20 @@ */ /** - * Stream wrapper type flag -- not visible in the UI or accessible via web, - * but readable and writable. E.g. the temporary directory for uploads. + * Not visible in the UI or accessible via web, but readable and writable. + * E.g. the temporary directory for uploads. */ - const HIDDEN = 0x0012; + const HIDDEN = 0x000C; /** * Hidden, readable and writeable using local files. */ - const LOCAL_HIDDEN = 0x0013; + const LOCAL_HIDDEN = 0x000D; /** * Visible, readable and writeable. */ - const WRITE_VISIBLE = 0x0022; + const WRITE_VISIBLE = 0x001C; /** * Visible and read-only. @@ -87,18 +87,18 @@ const READ_VISIBLE = 0x0014; /** - * Stream wrapper type flag -- This is the default 'type' falg. - * This does not include StreamWrapperInterface::LOCAL, because PHP grants a - * greater trust level to local files (for example, they can be used in an - * "include" statement, regardless of the "allow_url_include" setting), so - * stream wrappers need to explicitly opt-in to this. + * This is the default 'type' falg. This does not include + * StreamWrapperInterface::LOCAL, because PHP grants a greater trust level to + * local files (for example, they can be used in an "include" statement, + * regardless of the "allow_url_include" setting), so stream wrappers need to + * explicitly opt-in to this. */ - const NORMAL = 0x0022; + const NORMAL = 0x001C; /** * Visible, readable and writeable using local files. */ - const LOCAL_NORMAL = 0x0023; + const LOCAL_NORMAL = 0x001D; /** * Returns the type of stream wrapper. diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php index 4599085..d331420 100644 --- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php @@ -113,7 +113,7 @@ public function getWrappers($filter = StreamWrapperInterface::ALL) { public function getNames($filter = StreamWrapperInterface::ALL) { $names = array(); foreach (array_keys($this->getWrappers($filter)) as $scheme) { - $name[$scheme] = $this->getViaScheme($scheme)->getName(); + $names[$scheme] = $this->getViaScheme($scheme)->getName(); } return $names; @@ -123,12 +123,12 @@ public function getNames($filter = StreamWrapperInterface::ALL) { * @todo */ public function getDescriptions($filter = StreamWrapperInterface::ALL) { - $names = array(); + $descriptions = array(); foreach (array_keys($this->getWrappers($filter)) as $scheme) { - $name[$scheme] = $this->getViaScheme($scheme)->getDescription(); + $descriptions[$scheme] = $this->getViaScheme($scheme)->getDescription(); } - return $names; + return $descriptions; } /** diff --git a/core/modules/editor/editor.admin.inc b/core/modules/editor/editor.admin.inc index 80b4ec0..75f96f0 100644 --- a/core/modules/editor/editor.admin.inc +++ b/core/modules/editor/editor.admin.inc @@ -53,7 +53,7 @@ function editor_image_upload_settings_form(Editor $editor) { // Any visible, writable wrapper can potentially be used for uploads, // including a remote file system that integrates with a CDN. - $stream_wrappers = \Drupal::service('stream_wrapper_manager')->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE); + $options = \Drupal::service('stream_wrapper_manager')->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE); if (!empty($options)) { $form['scheme'] = array( '#type' => 'radios', @@ -67,8 +67,8 @@ function editor_image_upload_settings_form(Editor $editor) { // Set data- attributes with human-readable names for all possible stream // wrappers, so that drupal.ckeditor.drupalimage.admin's summary rendering // can use that. - foreach ($stream_wrappers as $scheme => $info) { - $form['scheme'][$scheme]['#attributes']['data-label'] = t('Storage: @name', array('@name' => $info['name'])); + foreach (\Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE) as $scheme => $name) { + $form['scheme'][$scheme]['#attributes']['data-label'] = t('Storage: @name', array('@name' => $name)); } $form['directory'] = array( diff --git a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php index 139f1f7..73d663d 100644 --- a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php +++ b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php @@ -92,9 +92,7 @@ public function buildForm(array $form, array &$form_state) { ); // Any visible, writeable wrapper can potentially be used for the files // directory, including a remote file system that integrates with a CDN. - $options = array_map(function ($wrapper) { - return String::checkPlain($wrapper['description']); - }, $this->streamWrapperManager->getWrappers(StreamWrapperInterface::WRITE_VISIBLE)); + $options = $this->streamWrapperManager->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE); if (!empty($options)) { $form['file_default_scheme'] = array(