' . t('About') . '';
$output .= '
' . t('The RESTful Web Services module provides a framework for exposing REST resources on your site. It provides support for content entity types such as the main site content, comments, custom blocks, taxonomy terms, and user accounts, etc. (see the Field module help page for more information about entities). REST support for content items of the Node module is enabled by default, and support for other types of content entities can be enabled. Other modules may add support for other types of REST resources. For more information, see the online documentation for the RESTful Web Services module.', [':rest' => 'https://www.drupal.org/documentation/modules/rest', ':field' => (\Drupal::moduleHandler()->moduleExists('field')) ? Url::fromRoute('help.page', ['name' => 'field'])->toString() : '#']) . '
';
$output .= '' . t('Uses') . '
';
$output .= '';
$output .= '- ' . t('Installing supporting modules') . '
';
$output .= '- ' . t('In order to use REST on a web site, you need to install modules that provide serialization and authentication services. You can use the Core module HAL for serialization and HTTP Basic Authentication for authentication, or install a contributed or custom module.', [':hal' => (\Drupal::moduleHandler()->moduleExists('hal')) ? Url::fromRoute('help.page', ['name' => 'hal'])->toString() : 'https://www.drupal.org/docs/8/core/modules/hal/overview', ':basic_auth' => (\Drupal::moduleHandler()->moduleExists('basic_auth')) ? Url::fromRoute('help.page', ['name' => 'basic_auth'])->toString() : 'https://www.drupal.org/docs/8/core/modules/basic_auth/overview']) . '
';
$output .= '- ' . t('Enabling REST support for an entity type') . '
';
$output .= '- ' . t('REST support for content types (provided by the Node module) is enabled by default. To enable support for other content entity types, you can use a process based on configuration editing or the contributed REST UI module.', [':node' => (\Drupal::moduleHandler()->moduleExists('node')) ? Url::fromRoute('help.page', ['name' => 'node'])->toString() : '#', ':config' => 'https://www.drupal.org/documentation/modules/rest', ':restui' => 'https://www.drupal.org/project/restui']) . '
';
$output .= '- ' . t('You will also need to grant anonymous users permission to perform each of the REST operations you want to be available, and set up authentication properly to authorize web requests.') . '
';
$output .= '- ' . t('General') . '
';
$output .= '- ' . t('The RESTful Web Services and JSON:API modules serve similar purposes. Read the comparison of the RESTFul Web Services and JSON:API modules to determine the best choice for your site.', [
':rest-docs' => 'https://www.drupal.org/docs/8/core/modules/rest',
':jsonapi-docs' => 'https://www.drupal.org/docs/8/modules/json-api',
':comparison' => 'https://www.drupal.org/docs/8/modules/jsonapi/jsonapi-vs-cores-rest-module',
]) . '
';
$output .= '
';
return $output;
}
}
/**
* Implements hook_ENTITY_TYPE_presave().
*
* @see rest_update_8401()
*/
function rest_view_presave(ViewEntityInterface $view) {
// 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) {
// The provider belongs to the module that declares it as a service.
if (strtok($provider_data->_serviceId, '.') === $auth_option) {
return $provider_id;
}
}
return $auth_option;
};
foreach (array_keys($view->get('display')) as $display_id) {
$display = &$view->getDisplay($display_id);
if ($display['display_plugin'] === 'rest_export' && !empty($display['display_options']['auth'])) {
$display['display_options']['auth'] = array_map($process_auth, $display['display_options']['auth']);
}
}
}