core/modules/rest/rest.install | 6 +++--- core/modules/rest/rest.post_update.php | 4 ---- core/modules/rest/src/Entity/ConfigDependencies.php | 4 +++- core/modules/rest/src/RestResourceConfigInterface.php | 2 +- .../ResourceGranularityRestResourcesConfigEntitiesUpdateTest.php | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/modules/rest/rest.install b/core/modules/rest/rest.install index 5cdfa6e..a52aa9f 100644 --- a/core/modules/rest/rest.install +++ b/core/modules/rest/rest.install @@ -5,7 +5,7 @@ * Install, update and uninstall functions for the rest module. */ -use Drupal\rest\Entity\RestResourceConfig; +use \Drupal\rest\RestResourceConfigInterface; /** * Implements hook_requirements(). @@ -50,7 +50,7 @@ function rest_update_8202() { foreach ($config_factory->listAll('rest.resource.') as $resource_config_name) { $resource_config_entity = $config_factory->getEditable($resource_config_name); - if ($resource_config_entity->get('granularity') === 'method') { + if ($resource_config_entity->get('granularity') === RestResourceConfigInterface::METHOD_GRANULARITY) { $configuration = $resource_config_entity->get('configuration'); $format_and_auth_configuration = []; @@ -68,7 +68,7 @@ function rest_update_8202() { 'formats' => $configuration['GET']['supported_formats'], 'authentication' => $configuration['GET']['supported_auth'] ]); - $resource_config_entity->set('granularity', 'resource'); + $resource_config_entity->set('granularity', RestResourceConfigInterface::RESOURCE_GRANULARITY); $resource_config_entity->save(TRUE); } } diff --git a/core/modules/rest/rest.post_update.php b/core/modules/rest/rest.post_update.php index 7068662..cd2d584 100644 --- a/core/modules/rest/rest.post_update.php +++ b/core/modules/rest/rest.post_update.php @@ -16,10 +16,6 @@ /** * Create REST resource configuration entities. * - * @todo https://www.drupal.org/node/2721595 Automatically upgrade those REST - * resource config entities that have the same formats/auth mechanisms for all - * methods to "granular: resource". - * * @see rest_update_8201() */ function rest_post_update_create_rest_resource_config_entities() { diff --git a/core/modules/rest/src/Entity/ConfigDependencies.php b/core/modules/rest/src/Entity/ConfigDependencies.php index 5d5bb63..5362d91 100644 --- a/core/modules/rest/src/Entity/ConfigDependencies.php +++ b/core/modules/rest/src/Entity/ConfigDependencies.php @@ -92,7 +92,9 @@ public function calculateDependencies(RestResourceConfigInterface $rest_config) } } - sort($dependencies['module']); + if (isset($dependencies['module'])) { + sort($dependencies['module']); + } return $dependencies; } diff --git a/core/modules/rest/src/RestResourceConfigInterface.php b/core/modules/rest/src/RestResourceConfigInterface.php index 0792634..601bb0e 100644 --- a/core/modules/rest/src/RestResourceConfigInterface.php +++ b/core/modules/rest/src/RestResourceConfigInterface.php @@ -16,7 +16,7 @@ const METHOD_GRANULARITY = 'method'; /** - * Granularity value for per-resourceconfiguration. + * Granularity value for per-resource configuration. */ const RESOURCE_GRANULARITY = 'resource'; diff --git a/core/modules/rest/src/Tests/Update/ResourceGranularityRestResourcesConfigEntitiesUpdateTest.php b/core/modules/rest/src/Tests/Update/ResourceGranularityRestResourcesConfigEntitiesUpdateTest.php index 3dda20d..c8f76ab 100644 --- a/core/modules/rest/src/Tests/Update/ResourceGranularityRestResourcesConfigEntitiesUpdateTest.php +++ b/core/modules/rest/src/Tests/Update/ResourceGranularityRestResourcesConfigEntitiesUpdateTest.php @@ -31,7 +31,7 @@ public function setDatabaseDumpFiles() { /** * Tests rest_update_8202(). */ - public function testResourcesConvertedToConfigEntities() { + public function testMethodGranularityResourcesConvertedToResourceGranularityResources() { /** @var \Drupal\Core\Entity\EntityStorageInterface $resource_config_storage */ $resource_config_storage = $this->container->get('entity_type.manager')->getStorage('rest_resource_config');