diff --git a/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php b/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php index aa38d37..cf2fa1f 100644 --- a/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php @@ -52,11 +52,6 @@ public function getImplementations($hook) { case 'user_role_load': return array(); - // t() (called indirectly by \Drupal\Core\StreamWrapper\PublicStream) - // needs this. Other schema calls aren't supported. - case 'schema': - return array('locale'); - default: throw new \LogicException("Invoking hooks $hook is not supported during updates"); } diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php index 5c1ee6f..b32d1e3 100644 --- a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php @@ -43,6 +43,13 @@ protected $uri; /** + * {@inheritdoc} + */ + public static function getType() { + return StreamWrapperInterface::NORMAL; + } + + /** * Gets the path that the wrapper is responsible for. * * @todo Review this method name in D8 per http://drupal.org/node/701358. diff --git a/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php b/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php index 899644a..6bcd56b 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php @@ -18,12 +18,22 @@ class PrivateStream extends LocalStream { /** * {@inheritdoc} */ - public static function info() { - return array( - 'name' => 'Private files', - 'description' => 'Private local files served by Drupal.', - 'type' => StreamWrapperInterface::LOCAL_NORMAL, - ); + public static function getType() { + return StreamWrapperInterface::LOCAL_NORMAL; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return t('Private files'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return t('Private local files served by Drupal.'); } /** diff --git a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php index ff6e243..e028ad0 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php @@ -18,12 +18,22 @@ class PublicStream extends LocalStream { /** * {@inheritdoc} */ - public static function info() { - return array( - 'name' => 'Public files', - 'description' => 'Public local files served by the webserver.', - 'type' => StreamWrapperInterface::LOCAL_NORMAL, - ); + public static function getType() { + return StreamWrapperInterface::LOCAL_NORMAL; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return t('Public files'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return t('Public local files served by the webserver.'); } /** diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php index d2869e1..9992e1e 100644 --- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php @@ -101,17 +101,27 @@ const LOCAL_NORMAL = 0x0023; /** - * Returns the stream wrapper definition. + * Returns the type of stream wrapper. * - * @todo + * @return int + */ + public static function getType(); + + /** + * Returns the name of the stream wrapper for use in the UI. * - * @return array - * An array with the keys: - * - name - * - description - * - type + * @return string + * The stream wrapper name. + */ + public function getName(); + + /** + * Returns the description of the stream wrapper for use in the UI. + * + * @return string + * The stream wrapper description. */ - public static function info(); + public function getDescription(); /** * Sets the absolute stream resource URI. diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php index 9da44d5..4599085 100644 --- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php @@ -108,6 +108,30 @@ public function getWrappers($filter = StreamWrapperInterface::ALL) { } /** + * @todo + */ + public function getNames($filter = StreamWrapperInterface::ALL) { + $names = array(); + foreach (array_keys($this->getWrappers($filter)) as $scheme) { + $name[$scheme] = $this->getViaScheme($scheme)->getName(); + } + + return $names; + } + + /** + * @todo + */ + public function getDescriptions($filter = StreamWrapperInterface::ALL) { + $names = array(); + foreach (array_keys($this->getWrappers($filter)) as $scheme) { + $name[$scheme] = $this->getViaScheme($scheme)->getDescription(); + } + + return $names; + } + + /** * Returns a stream wrapper via scheme. * * @param string $scheme @@ -183,8 +207,9 @@ protected function getWrapper($scheme, $uri) { * The stream wrapper class. */ public function addStreamWrapper($service_id, $class, $scheme) { - $info = $class::info() + array('type' => StreamWrapperInterface::NORMAL); + $info = array(); $info['class'] = $class; + $info['type'] = $class::getType(); $this->services[$scheme] = $service_id; $this->info[$scheme] = $info; } diff --git a/core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php b/core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php index 0f4acf5..0ea466c 100644 --- a/core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/TemporaryStream.php @@ -18,12 +18,22 @@ class TemporaryStream extends LocalStream { /** * {@inheritdoc} */ - public static function info() { - return array( - 'name' => 'Temporary files', - 'description' => 'Temporary local files for upload and previews.', - 'type' => StreamWrapperInterface::LOCAL_HIDDEN, - ); + public static function getType() { + return StreamWrapperInterface::LOCAL_HIDDEN; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return t('Temporary files'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return t('Temporary local files for upload and previews.'); } /** diff --git a/core/modules/editor/editor.admin.inc b/core/modules/editor/editor.admin.inc index 59c61b8..80b4ec0 100644 --- a/core/modules/editor/editor.admin.inc +++ b/core/modules/editor/editor.admin.inc @@ -53,10 +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 = file_get_stream_wrappers(StreamWrapperInterface::WRITE_VISIBLE); - foreach ($stream_wrappers as $scheme => $info) { - $options[$scheme] = $info['description']; - } + $stream_wrappers = \Drupal::service('stream_wrapper_manager')->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE); if (!empty($options)) { $form['scheme'] = array( '#type' => 'radios', diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php index f8d5360..6f190a6 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php @@ -129,10 +129,7 @@ public function settingsForm(array $form, array &$form_state, $has_data) { ), ); - $scheme_options = array(); - foreach (file_get_stream_wrappers(StreamWrapperInterface::WRITE_VISIBLE) as $scheme => $stream_wrapper) { - $scheme_options[$scheme] = $stream_wrapper['name']; - } + $scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE); $element['uri_scheme'] = array( '#type' => 'radios', '#title' => t('Upload destination'), diff --git a/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyReadOnlyStreamWrapper.php b/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyReadOnlyStreamWrapper.php index 2ffae29..ab2f7b8 100644 --- a/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyReadOnlyStreamWrapper.php +++ b/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyReadOnlyStreamWrapper.php @@ -19,11 +19,15 @@ class DummyReadOnlyStreamWrapper extends LocalReadOnlyStream { /** * {@inheritdoc} */ - public static function info() { - return array( - 'name' => t('Dummy files (readonly)'), - 'description' => t('Dummy wrapper for simpletest (readonly).'), - ); + public function getName() { + return t('Dummy files (readonly)'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return t('Dummy wrapper for simpletest (readonly).'); } function getDirectoryPath() { diff --git a/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyRemoteStreamWrapper.php b/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyRemoteStreamWrapper.php index 2ac36d5..7e9f089 100644 --- a/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyRemoteStreamWrapper.php +++ b/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyRemoteStreamWrapper.php @@ -21,11 +21,15 @@ class DummyRemoteStreamWrapper extends PublicStream { /** * {@inheritdoc} */ - public static function info() { - return array( - 'name' => t('Dummy files (remote)'), - 'description' => t('Dummy wrapper for simpletest (remote).'), - ); + public function getName() { + return t('Dummy files (remote)'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return t('Dummy wrapper for simpletest (remote).'); } function realpath() { diff --git a/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyStreamWrapper.php b/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyStreamWrapper.php index b58d915..295426d 100644 --- a/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyStreamWrapper.php +++ b/core/modules/file/tests/file_test/lib/Drupal/file_test/StreamWrapper/DummyStreamWrapper.php @@ -19,11 +19,15 @@ class DummyStreamWrapper extends LocalStream { /** * {@inheritdoc} */ - public static function info() { - return array( - 'name' => t('Dummy files'), - 'description' => t('Dummy wrapper for simpletest.'), - ); + public function getName() { + return t('Dummy files'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return t('Dummy wrapper for simpletest.'); } function getDirectoryPath() { diff --git a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php index ab93fbd..9685943 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php @@ -150,10 +150,7 @@ public function settingsForm(array $form, array &$form_state, $has_data) { // the field. $settings = $this->getFieldDefinition()->getField()->getSettings(); - $scheme_options = array(); - foreach (file_get_stream_wrappers(StreamWrapperInterface::WRITE_VISIBLE) as $scheme => $stream_wrapper) { - $scheme_options[$scheme] = $stream_wrapper['name']; - } + $scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE); $element['uri_scheme'] = array( '#type' => 'radios', '#title' => t('Upload destination'), diff --git a/core/modules/locale/lib/Drupal/locale/StreamWrapper/TranslationsStream.php b/core/modules/locale/lib/Drupal/locale/StreamWrapper/TranslationsStream.php index 67be78f..44c8957 100644 --- a/core/modules/locale/lib/Drupal/locale/StreamWrapper/TranslationsStream.php +++ b/core/modules/locale/lib/Drupal/locale/StreamWrapper/TranslationsStream.php @@ -22,12 +22,22 @@ class TranslationsStream extends LocalStream { /** * {@inheritdoc} */ - public static function info() { - return array( - 'name' => 'Translation files', - 'description' => 'Translation files', - 'type' => StreamWrapperInterface::LOCAL_HIDDEN, - ); + public static function getType() { + return StreamWrapperInterface::LOCAL_HIDDEN; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return t('Translation files'); + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return t('Translation files'); } /**