jsonapi.module | 16 ---------------- src/JsonapiServiceProvider.php | 11 ----------- tests/src/Functional/CommentTest.php | 14 ++------------ tests/src/Functional/MediaTest.php | 13 +------------ tests/src/Functional/ResourceTestBase.php | 4 ---- 5 files changed, 3 insertions(+), 55 deletions(-) diff --git a/jsonapi.module b/jsonapi.module index 1201a3f..7051f4a 100644 --- a/jsonapi.module +++ b/jsonapi.module @@ -32,22 +32,6 @@ function jsonapi_help($route_name, RouteMatchInterface $route_match) { } /** - * Implements hook_entity_bundle_field_info(). - */ -function jsonapi_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) { - $fields = []; - - if (floatval(\Drupal::VERSION) < 8.6 && $entity_type->id() == 'taxonomy_term') { - // Only terms in the same bundle can be a parent. - $fields['parent'] = clone $base_field_definitions['parent']; - $fields['parent']->setSetting('handler_settings', ['target_bundles' => [$bundle]]); - return $fields; - } - - return $fields; -} - -/** * Implements hook_entity_bundle_create(). */ function jsonapi_entity_bundle_create() { diff --git a/src/JsonapiServiceProvider.php b/src/JsonapiServiceProvider.php index d04181e..79cef20 100644 --- a/src/JsonapiServiceProvider.php +++ b/src/JsonapiServiceProvider.php @@ -21,17 +21,6 @@ class JsonapiServiceProvider implements ServiceModifierInterface, ServiceProvide * {@inheritdoc} */ public function alter(ContainerBuilder $container) { - // @todo Remove when we stop supporting Drupal 8.5. - if (floatval(\Drupal::VERSION) < 8.6) { - // Swap the cache service back. - $definition = $container->getDefinition('jsonapi.resource_type.repository'); - $definition->setArgument(3, new Reference('cache.static')); - $container->setDefinition('jsonapi.resource_type.repository', $definition); - - // Drop the new service definition. - $container->removeDefinition('cache.jsonapi_resource_types'); - } - if ($container->has('http_middleware.negotiation') && is_a($container->getDefinition('http_middleware.negotiation') ->getClass(), '\Drupal\Core\StackMiddleware\NegotiationMiddleware', TRUE) ) { diff --git a/tests/src/Functional/CommentTest.php b/tests/src/Functional/CommentTest.php index 683b26b..c2511ff 100644 --- a/tests/src/Functional/CommentTest.php +++ b/tests/src/Functional/CommentTest.php @@ -310,12 +310,7 @@ class CommentTest extends ResourceTestBase { // DX: 422 when missing 'entity_type' field. $request_options[RequestOptions::BODY] = Json::encode($remove_field($this->getPostDocument(), 'attributes', 'entity_type')); $response = $this->request('POST', $url, $request_options); - if (floatval(\Drupal::VERSION) >= 8.7) { - $this->assertResourceErrorResponse(422, 'entity_type: This value should not be null.', NULL, $response, '/data/attributes/entity_type'); - } - else { - $this->assertResourceErrorResponse(500, 'The "" entity type does not exist.', $url, $response, FALSE); - } + $this->assertResourceErrorResponse(422, 'entity_type: This value should not be null.', NULL, $response, '/data/attributes/entity_type'); // DX: 422 when missing 'entity_id' field. $request_options[RequestOptions::BODY] = Json::encode($remove_field($this->getPostDocument(), 'relationships', 'entity_id')); @@ -331,12 +326,7 @@ class CommentTest extends ResourceTestBase { // DX: 422 when missing 'field_name' field. $request_options[RequestOptions::BODY] = Json::encode($remove_field($this->getPostDocument(), 'attributes', 'field_name')); $response = $this->request('POST', $url, $request_options); - if (floatval(\Drupal::VERSION) >= 8.7) { - $this->assertResourceErrorResponse(422, 'field_name: This value should not be null.', NULL, $response, '/data/attributes/field_name'); - } - else { - $this->assertSame(500, $response->getStatusCode()); - } + $this->assertResourceErrorResponse(422, 'field_name: This value should not be null.', NULL, $response, '/data/attributes/field_name'); } /** diff --git a/tests/src/Functional/MediaTest.php b/tests/src/Functional/MediaTest.php index 1c86024..5a84540 100644 --- a/tests/src/Functional/MediaTest.php +++ b/tests/src/Functional/MediaTest.php @@ -134,7 +134,7 @@ class MediaTest extends ResourceTestBase { $thumbnail = File::load(3); $author = User::load($this->entity->getOwnerId()); $self_url = Url::fromUri('base:/jsonapi/media/camelids/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); - $data = [ + return [ 'jsonapi' => [ 'meta' => [ 'links' => [ @@ -232,12 +232,6 @@ class MediaTest extends ResourceTestBase { ], ], ]; - // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) < 8.6) { - $data['data']['relationships']['thumbnail']['data']['meta']['alt'] = 'Thumbnail'; - $data['data']['relationships']['thumbnail']['data']['meta']['title'] = 'Llama'; - } - return $data; } /** @@ -324,11 +318,6 @@ class MediaTest extends ResourceTestBase { 'height' => 180, 'title' => NULL, ]; - // @todo Make this unconditional when JSON:API requires Drupal 8.6 or newer. - if (floatval(\Drupal::VERSION) < 8.6) { - $data['meta']['alt'] = 'Thumbnail'; - $data['meta']['title'] = 'Llama'; - } return $data; case 'field_media_file': diff --git a/tests/src/Functional/ResourceTestBase.php b/tests/src/Functional/ResourceTestBase.php index ba80706..c77661a 100644 --- a/tests/src/Functional/ResourceTestBase.php +++ b/tests/src/Functional/ResourceTestBase.php @@ -1751,10 +1751,6 @@ abstract class ResourceTestBase extends BrowserTestBase { $detail = 'The current user is not allowed to view this relationship.'; if (!$entity->access('view') && $entity->access('view label') && $access instanceof AccessResultReasonInterface && empty($access->getReason())) { $access->setReason("The user only has authorization for the 'view label' operation."); - // @todo Remove when we stop supporting Drupal 8.5. - if (floatval(\Drupal::VERSION) < 8.6 && $relationship_field_name === 'roles' && static::$entityTypeId === 'user' && $access->getCacheContexts() === ['user.permissions']) { - $access = $access->setReason(''); - } } $via_link = Url::fromRoute( sprintf('jsonapi.%s.%s.related', $base_resource_identifier['type'], $relationship_field_name),