diff --git a/core/modules/rest/config/install/rest.settings.yml b/core/modules/rest/config/install/rest.settings.yml index 0a44346..4dde897 100644 --- a/core/modules/rest/config/install/rest.settings.yml +++ b/core/modules/rest/config/install/rest.settings.yml @@ -4,7 +4,7 @@ # setting up SSL. # There are alternatives to Basic_auth in contrib such as OAuth module. resources: - entity:node: + entity__node: GET: supported_formats: - hal_json @@ -30,7 +30,7 @@ resources: # resource: # # resources: -# entity:node: +# entity__node: # GET: # supported_formats: # - json diff --git a/core/modules/rest/rest.api.php b/core/modules/rest/rest.api.php index 2f3f6ee..1ce2251 100644 --- a/core/modules/rest/rest.api.php +++ b/core/modules/rest/rest.api.php @@ -17,15 +17,15 @@ * The collection of resource definitions. */ function hook_rest_resource_alter(&$definitions) { - if (isset($definitions['entity:node'])) { + if (isset($definitions['entity__node'])) { // We want to handle REST requests regarding nodes with our own plugin // class. - $definitions['entity:node']['class'] = 'Drupal\mymodule\Plugin\rest\resource\NodeResource'; + $definitions['entity__node']['class'] = 'Drupal\mymodule\Plugin\rest\resource\NodeResource'; // Serialized nodes should be expanded to my specific node class. - $definitions['entity:node']['serialization_class'] = 'Drupal\mymodule\Entity\MyNode'; + $definitions['entity__node']['serialization_class'] = 'Drupal\mymodule\Entity\MyNode'; } // We don't want Views to show up in the array of plugins at all. - unset($definitions['entity:view']); + unset($definitions['entity__view']); } /** diff --git a/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php b/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php index 3d987a2..59db920 100644 --- a/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php +++ b/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php @@ -74,7 +74,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { // Add in the default plugin configuration and the resource type. foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { $this->derivatives[$entity_type_id] = array( - 'id' => 'entity:' . $entity_type_id, + 'id' => 'entity__' . $entity_type_id, 'entity_type' => $entity_type_id, 'serialization_class' => $entity_type->getClass(), 'label' => $entity_type->getLabel(), diff --git a/core/modules/rest/src/Plugin/ResourceBase.php b/core/modules/rest/src/Plugin/ResourceBase.php index 70d6268..fac6eaf 100644 --- a/core/modules/rest/src/Plugin/ResourceBase.php +++ b/core/modules/rest/src/Plugin/ResourceBase.php @@ -78,7 +78,7 @@ public static function create(ContainerInterface $container, array $configuratio * Implements ResourceInterface::permissions(). * * Every plugin operation method gets its own user permission. Example: - * "restful delete entity:node" with the title "Access DELETE on Node + * "restful delete entity__node" with the title "Access DELETE on Node * resource". */ public function permissions() { diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 2c5eea9..73691ce 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -226,7 +226,7 @@ protected function getBaseRoute($canonical_path, $method) { $definition = $this->getPluginDefinition(); $parameters = $route->getOption('parameters') ?: array(); - $parameters[$definition['entity_type']]['type'] = 'entity:' . $definition['entity_type']; + $parameters[$definition['entity_type']]['type'] = 'entity__' . $definition['entity_type']; $route->setOption('parameters', $parameters); return $route; diff --git a/core/modules/rest/src/Tests/AuthTest.php b/core/modules/rest/src/Tests/AuthTest.php index 1919aa6..6a7aa2c 100644 --- a/core/modules/rest/src/Tests/AuthTest.php +++ b/core/modules/rest/src/Tests/AuthTest.php @@ -31,7 +31,7 @@ public function testRead() { $entity_type = 'entity_test'; // Enable a test resource through GET method and basic HTTP authentication. - $this->enableService('entity:' . $entity_type, 'GET', NULL, array('basic_auth')); + $this->enableService('entity__' . $entity_type, 'GET', NULL, array('basic_auth')); // Create an entity programmatically. $entity = $this->entityCreate($entity_type); @@ -49,7 +49,7 @@ public function testRead() { // resources via the REST API, but the request is authenticated // with session cookies. $permissions = $this->entityPermissions($entity_type, 'view'); - $permissions[] = 'restful get entity:' . $entity_type; + $permissions[] = 'restful get entity__' . $entity_type; $account = $this->drupalCreateUser($permissions); $this->drupalLogin($account); diff --git a/core/modules/rest/src/Tests/CreateTest.php b/core/modules/rest/src/Tests/CreateTest.php index 1d143ab..8fee56e 100644 --- a/core/modules/rest/src/Tests/CreateTest.php +++ b/core/modules/rest/src/Tests/CreateTest.php @@ -46,12 +46,12 @@ protected function setUp() { public function testCreateResourceRestApiNotEnabled() { $entity_type = 'entity_test'; // Enables the REST service for a specific entity type. - $this->enableService('entity:' . $entity_type, 'POST'); + $this->enableService('entity__' . $entity_type, 'POST'); // Get the necessary user permissions to create the current entity type. $permissions = $this->entityPermissions($entity_type, 'create'); // POST method must be allowed for the current entity type. - $permissions[] = 'restful post entity:' . $entity_type; + $permissions[] = 'restful post entity__' . $entity_type; // Create the user. $account = $this->drupalCreateUser($permissions); @@ -81,9 +81,9 @@ public function testCreateResourceRestApiNotEnabled() { public function testCreateWithoutPermission() { $entity_type = 'entity_test'; // Enables the REST service for 'entity_test' entity type. - $this->enableService('entity:' . $entity_type, 'POST'); + $this->enableService('entity__' . $entity_type, 'POST'); $permissions = $this->entityPermissions($entity_type, 'create'); - // Create a user without the 'restful post entity:entity_test permission. + // Create a user without the 'restful post entity__entity_test permission. $account = $this->drupalCreateUser($permissions); $this->drupalLogin($account); // Populate some entity properties before create the entity. @@ -105,7 +105,7 @@ public function testCreateWithoutPermission() { public function testCreateEntityTest() { $entity_type = 'entity_test'; // Enables the REST service for 'entity_test' entity type. - $this->enableService('entity:' . $entity_type, 'POST'); + $this->enableService('entity__' . $entity_type, 'POST'); // Create two accounts with the required permissions to create resources. // The second one has administrative permissions. $accounts = $this->createAccountPerEntity($entity_type); @@ -172,7 +172,7 @@ public function testCreateEntityTest() { public function testCreateNode() { $entity_type = 'node'; // Enables the REST service for 'node' entity type. - $this->enableService('entity:' . $entity_type, 'POST'); + $this->enableService('entity__' . $entity_type, 'POST'); // Create two accounts that have the required permissions to create // resources. The second one has administrative permissions. $accounts = $this->createAccountPerEntity($entity_type); @@ -230,7 +230,7 @@ public function testCreateNode() { public function testCreateUser() { $entity_type = 'user'; // Enables the REST service for 'user' entity type. - $this->enableService('entity:' . $entity_type, 'POST'); + $this->enableService('entity__' . $entity_type, 'POST'); // Create two accounts that have the required permissions to create // resources. The second one has administrative permissions. $accounts = $this->createAccountPerEntity($entity_type); @@ -287,7 +287,7 @@ public function createAccountPerEntity($entity_type) { // Get the necessary user permissions for the current $entity_type creation. $permissions = $this->entityPermissions($entity_type, 'create'); // POST method must be allowed for the current entity type. - $permissions[] = 'restful post entity:' . $entity_type; + $permissions[] = 'restful post entity__' . $entity_type; // Create user without administrative permissions. $accounts[] = $this->drupalCreateUser($permissions); // Add administrative permissions for nodes and users. diff --git a/core/modules/rest/src/Tests/CsrfTest.php b/core/modules/rest/src/Tests/CsrfTest.php index a686f448..e1490d6 100644 --- a/core/modules/rest/src/Tests/CsrfTest.php +++ b/core/modules/rest/src/Tests/CsrfTest.php @@ -41,12 +41,12 @@ class CsrfTest extends RESTTestBase { protected function setUp() { parent::setUp(); - $this->enableService('entity:' . $this->testEntityType, 'POST', 'hal_json', array('basic_auth', 'cookie')); + $this->enableService('entity__' . $this->testEntityType, 'POST', 'hal_json', array('basic_auth', 'cookie')); // Create a user account that has the required permissions to create // resources via the REST API. $permissions = $this->entityPermissions($this->testEntityType, 'create'); - $permissions[] = 'restful post entity:' . $this->testEntityType; + $permissions[] = 'restful post entity__' . $this->testEntityType; $this->account = $this->drupalCreateUser($permissions); // Serialize an entity to a string to use in the content body of the POST diff --git a/core/modules/rest/src/Tests/DeleteTest.php b/core/modules/rest/src/Tests/DeleteTest.php index b95ee9f..b190878 100644 --- a/core/modules/rest/src/Tests/DeleteTest.php +++ b/core/modules/rest/src/Tests/DeleteTest.php @@ -33,11 +33,11 @@ public function testDelete() { // controllers are implemented. $entity_types = array('entity_test', 'node'); foreach ($entity_types as $entity_type) { - $this->enableService('entity:' . $entity_type, 'DELETE'); + $this->enableService('entity__' . $entity_type, 'DELETE'); // Create a user account that has the required permissions to delete // resources via the REST API. $permissions = $this->entityPermissions($entity_type, 'delete'); - $permissions[] = 'restful delete entity:' . $entity_type; + $permissions[] = 'restful delete entity__' . $entity_type; $account = $this->drupalCreateUser($permissions); $this->drupalLogin($account); diff --git a/core/modules/rest/src/Tests/NodeTest.php b/core/modules/rest/src/Tests/NodeTest.php index 8fecfd5..d3d3ec0 100644 --- a/core/modules/rest/src/Tests/NodeTest.php +++ b/core/modules/rest/src/Tests/NodeTest.php @@ -35,9 +35,9 @@ class NodeTest extends RESTTestBase { * The operation, one of 'view', 'create', 'update' or 'delete'. */ protected function enableNodeConfiguration($method, $operation) { - $this->enableService('entity:node', $method); + $this->enableService('entity__node', $method); $permissions = $this->entityPermissions('node', $operation); - $permissions[] = 'restful ' . strtolower($method) . ' entity:node'; + $permissions[] = 'restful ' . strtolower($method) . ' entity__node'; $account = $this->drupalCreateUser($permissions); $this->drupalLogin($account); } @@ -57,7 +57,7 @@ public function testNodes() { // Also check that JSON works and the routing system selects the correct // REST route. - $this->enableService('entity:node', 'GET', 'json'); + $this->enableService('entity__node', 'GET', 'json'); $this->httpRequest($node->urlInfo(), 'GET', NULL, 'application/json'); $this->assertResponse(200); $this->assertHeader('Content-type', 'application/json'); diff --git a/core/modules/rest/src/Tests/PageCacheTest.php b/core/modules/rest/src/Tests/PageCacheTest.php index 6696bf7..2d8f321 100644 --- a/core/modules/rest/src/Tests/PageCacheTest.php +++ b/core/modules/rest/src/Tests/PageCacheTest.php @@ -25,11 +25,11 @@ class PageCacheTest extends RESTTestBase { * Tests that configuration changes also clear the page cache. */ public function testConfigChangePageCache() { - $endpoint_id = 'entity:entity_test'; + $endpoint_id = 'entity__entity_test'; $this->enableService($endpoint_id, 'GET'); // Allow anonymous users to issue GET requests. $permissions = $this->entityPermissions('entity_test', 'view'); - $permissions[] = 'restful get entity:entity_test'; + $permissions[] = 'restful get entity__entity_test'; user_role_grant_permissions('anonymous', $permissions); // Create an entity programmatically. @@ -39,14 +39,14 @@ public function testConfigChangePageCache() { $this->httpRequest($entity->urlInfo(), 'GET', NULL, $this->defaultMimeType); $this->assertResponse(200, 'HTTP response code is correct.'); $this->assertHeader('x-drupal-cache', 'MISS'); - $this->assertCacheTag('config:entity:entity_test'); + $this->assertCacheTag('config:entity__entity_test'); $this->assertCacheTag('entity_test:1'); // Read it again, should be page-cached now. $this->httpRequest($entity->urlInfo(), 'GET', NULL, $this->defaultMimeType); $this->assertResponse(200, 'HTTP response code is correct.'); $this->assertHeader('x-drupal-cache', 'HIT'); - $this->assertCacheTag('config:entity:entity_test'); + $this->assertCacheTag('config:entity__entity_test'); $this->assertCacheTag('entity_test:1'); // Trigger an endpoint save which should clear the page cache, so we should get @@ -55,7 +55,7 @@ public function testConfigChangePageCache() { $this->httpRequest($entity->urlInfo(), 'GET', NULL, $this->defaultMimeType); $this->assertResponse(200, 'HTTP response code is correct.'); $this->assertHeader('x-drupal-cache', 'MISS'); - $this->assertCacheTag('config:entity:entity_test'); + $this->assertCacheTag('config:entity__entity_test'); $this->assertCacheTag('entity_test:1'); } diff --git a/core/modules/rest/src/Tests/ReadTest.php b/core/modules/rest/src/Tests/ReadTest.php index e7d29e9..e02a878 100644 --- a/core/modules/rest/src/Tests/ReadTest.php +++ b/core/modules/rest/src/Tests/ReadTest.php @@ -32,11 +32,11 @@ public function testRead() { // Define the entity types we want to test. $entity_types = array('entity_test', 'node'); foreach ($entity_types as $entity_type) { - $this->enableService('entity:' . $entity_type, 'GET'); + $this->enableService('entity__' . $entity_type, 'GET'); // Create a user account that has the required permissions to read // resources via the REST API. $permissions = $this->entityPermissions($entity_type, 'view'); - $permissions[] = 'restful get entity:' . $entity_type; + $permissions[] = 'restful get entity__' . $entity_type; $account = $this->drupalCreateUser($permissions); $this->drupalLogin($account); @@ -100,11 +100,11 @@ public function testRead() { */ public function testResourceStructure() { // Enable a service with a format restriction but no authentication. - $this->enableService('entity:node', 'GET', 'json'); + $this->enableService('entity__node', 'GET', 'json'); // Create a user account that has the required permissions to read // resources via the REST API. $permissions = $this->entityPermissions('node', 'view'); - $permissions[] = 'restful get entity:node'; + $permissions[] = 'restful get entity__node'; $account = $this->drupalCreateUser($permissions); $this->drupalLogin($account); diff --git a/core/modules/rest/src/Tests/ResourceTest.php b/core/modules/rest/src/Tests/ResourceTest.php index d9ac20c..2b74fef 100644 --- a/core/modules/rest/src/Tests/ResourceTest.php +++ b/core/modules/rest/src/Tests/ResourceTest.php @@ -36,7 +36,7 @@ protected function setUp() { */ public function testFormats() { /** @var \Drupal\rest\RestEndpointInterface $endpoint */ - $endpoint = $this->endpoint_storage->create(['id' => 'entity:entity_test']); + $endpoint = $this->endpoint_storage->create(['id' => 'entity__entity_test']); $endpoint->setSettings([ 'GET' => [ 'supported_auth' => [ @@ -63,7 +63,7 @@ public function testFormats() { */ public function testAuthentication() { /** @var \Drupal\rest\RestEndpointInterface $endpoint */ - $endpoint = $this->endpoint_storage->create(['id' => 'entity:entity_test']); + $endpoint = $this->endpoint_storage->create(['id' => 'entity__entity_test']); $endpoint->setSettings([ 'GET' => [ 'supported_formats' => [ diff --git a/core/modules/rest/src/Tests/UpdateTest.php b/core/modules/rest/src/Tests/UpdateTest.php index 481e33b..599c78b 100644 --- a/core/modules/rest/src/Tests/UpdateTest.php +++ b/core/modules/rest/src/Tests/UpdateTest.php @@ -36,7 +36,7 @@ public function testPatchUpdate() { // Create a user account that has the required permissions to create // resources via the REST API. $permissions = $this->entityPermissions($entity_type, 'update'); - $permissions[] = 'restful patch entity:' . $entity_type; + $permissions[] = 'restful patch entity__' . $entity_type; $account = $this->drupalCreateUser($permissions); $this->drupalLogin($account); @@ -170,9 +170,9 @@ public function testUpdateUser() { $serializer = $this->container->get('serializer'); $entity_type = 'user'; // Enables the REST service for 'user' entity type. - $this->enableService('entity:' . $entity_type, 'PATCH'); + $this->enableService('entity__' . $entity_type, 'PATCH'); $permissions = $this->entityPermissions($entity_type, 'update'); - $permissions[] = 'restful patch entity:' . $entity_type; + $permissions[] = 'restful patch entity__' . $entity_type; $account = $this->drupalCreateUser($permissions); $account->set('mail', 'old-email@example.com'); $this->drupalLogin($account);