diff --git a/core/modules/rest/rest.module b/core/modules/rest/rest.module index 70135e2127..ba61a17fea 100644 --- a/core/modules/rest/rest.module +++ b/core/modules/rest/rest.module @@ -35,7 +35,7 @@ function rest_help($route_name, RouteMatchInterface $route_match) { * @see rest_update_8401() */ function rest_view_presave(ViewEntityInterface $view) { - // Fix the auth options on import, much like what rest_update_8401 does. + // Fix the auth options on import, much like what rest_update_8401() does. $auth_providers = \Drupal::service('authentication_collector')->getSortedProviders(); $process_auth = function ($auth_option) use ($auth_providers) { foreach ($auth_providers as $provider_id => $provider_data) { diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index bac63a3b4c..7120391de8 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -87,7 +87,17 @@ class RestExport extends PathPluginBase implements ResponseDisplayPluginInterfac protected $authenticationCollector; /** - * The authentication providers, keyed by ID. + * The authentication providers, like 'cookie' and 'basic_auth'. + * + * @var string[] + */ + protected $authenticationProviderIds; + + /** + * The authentication providers, like 'cookie' and 'basic_auth'. + * + * @deprecated as of 8.4.x, will be removed in before Drupal 9.0.0, see + * https://www.drupal.org/node/2825204. * * @var string[] */ @@ -124,9 +134,14 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition parent::__construct($configuration, $plugin_id, $plugin_definition, $route_provider, $state); $this->renderer = $renderer; - // Values of "$this->authenticationProviders" - are module names, defining - // authentication providers. Only provider IDs should be used for choosing. - $this->authenticationProviders = array_keys($authentication_providers); + // $authentication_providers as defined in + // \Drupal\Core\DependencyInjection\Compiler\AuthenticationProviderPass + // and as such it is an array, with authentication providers (cookie, + // basic_auth) as keys and modules providing those as values (user, + // basic_auth). + $this->authenticationProviderIds = array_keys($authentication_providers); + // For BC reasons we keep around authenticationProviders as before. + $this->authenticationProviders = $authentication_providers; $this->formatProviders = $serializer_format_providers; } @@ -240,7 +255,7 @@ public function getContentType() { * An array to use as value for "#options" in the form element. */ public function getAuthOptions() { - return array_combine($this->authenticationProviders, $this->authenticationProviders); + return array_combine($this->authenticationProviderIds, $this->authenticationProviderIds); } /** @@ -478,8 +493,8 @@ public function calculateDependencies() { // During the update path the provider options might be wrong. This can // happen when any update function, like block_update_8300() triggers a // view to be saved. - return isset($this->authenticationProviders[$provider]) - ? $this->authenticationProviders[$provider] + return isset($this->authenticationProviderIds[$provider]) + ? $this->authenticationProviderIds[$provider] : NULL; }, $this->getOption('auth')))); diff --git a/core/modules/rest/tests/src/Kernel/Views/RestExportAuthTest.php b/core/modules/rest/tests/src/Kernel/Views/RestExportAuthTest.php index bb884f1787..9d32f7fcd1 100644 --- a/core/modules/rest/tests/src/Kernel/Views/RestExportAuthTest.php +++ b/core/modules/rest/tests/src/Kernel/Views/RestExportAuthTest.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\rest\Kernel\Views; use Drupal\Tests\views\Kernel\ViewsKernelTestBase; -use Drupal\views\Tests\ViewTestData; /** * Tests the auth option of rest exports.