diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php index 84d6d03..8c99f04 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php @@ -130,7 +130,7 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('state'), $container->get('content_negotiation'), $container->get('request'), - array_keys($container->get('authentication')->getSortedProviders()) + RestExport::getAuthProviders($container) ); } @@ -152,6 +152,18 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio } /** + * Extacts Authentication providers out of the Container. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface; + * The Dependency Injection Container. + * @return array + * An array of available Autentication Providers. + */ + private static function getAuthProviders(ContainerInterface $container) { + return array_keys($container->get('authentication')->getSortedProviders()); + } + + /** * {@inheritdoc} */ protected function getType() { @@ -260,7 +272,7 @@ public function optionsSummary(&$categories, &$options) { // Authentication. $auth = array_filter($this->getOption('auth')); if (empty($auth)) { - $auth = t('No authentication is set'); + $auth = $this->t('No authentication is set'); } else { $auth = implode(', ', $auth); @@ -268,7 +280,7 @@ public function optionsSummary(&$categories, &$options) { $options['auth'] = array( 'category' => 'path', - 'title' => t('Authentication'), + 'title' => $this->t('Authentication'), 'value' => views_ui_truncate($auth, 24), ); @@ -280,17 +292,17 @@ public function optionsSummary(&$categories, &$options) { } /** - * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::buildOptionsForm(). + * {@inheritdoc} */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); if ($form_state['section'] == 'auth') { - $form['#title'] .= t('The supported authentication methods of this view'); + $form['#title'] .= $this->t('The supported authentication methods of this view'); $form['auth'] = array( '#type' => 'checkboxes', - '#title' => t('Autentication methods'), - '#description' => t('These are the supported authentication providers for this view. When this view is requested, the client will be forced to authenticate himself with one of the selected providers.'), + '#title' => $this->t('Autentication methods'), + '#description' => $this->t('These are the supported authentication providers for this view. When this view is requested, the client will be forced to authenticate with one of the selected providers. Make sure you set the appropiate requirements at the Access section since the Authentication System will fallback to the anonymous user if it fails to authenticate. For example: require Access: Role | Authenticated User.'), '#options' => array_combine($this->authenticationProviders, $this->authenticationProviders), '#default_value' => array_filter($this->getOption('auth')), ); @@ -298,7 +310,7 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::submitOptionsForm(). + * {@inheritdoc} */ public function submitOptionsForm(&$form, &$form_state) { parent::submitOptionsForm($form, $form_state); @@ -330,7 +342,6 @@ public function collectRoutes(RouteCollection $collection) { $options = array( '_auth' => $auth, ); - $requirements['_user_is_logged_in'] = 'TRUE'; $route->addOptions($options); }