function rest_update_8201 in Drupal 8
Install the REST config entity type and fix old settings-based config.
See also
rest_post_update_create_rest_resource_config_entities()
File
- core/
modules/ rest/ rest.install, line 16 - Install, update and uninstall functions for the rest module.
Code
function rest_update_8201() {
\Drupal::entityDefinitionUpdateManager()
->installEntityType(new ConfigEntityType([
'id' => 'rest_resource_config',
'label' => new TranslatableMarkup('REST resource configuration'),
'config_prefix' => 'resource',
'admin_permission' => 'administer rest resources',
'label_callback' => 'getLabelFromPlugin',
'entity_keys' => [
'id' => 'id',
],
'config_export' => [
'id',
'plugin_id',
'granularity',
'configuration',
],
]));
\Drupal::state()
->set('rest_update_8201_resources', \Drupal::config('rest.settings')
->get('resources'));
\Drupal::configFactory()
->getEditable('rest.settings')
->clear('resources')
->save();
}