diff --cc jsonapi.services.yml index 3a97096,b5a609e..0000000 --- a/jsonapi.services.yml +++ b/jsonapi.services.yml @@@ -98,4 -94,29 +98,11 @@@ services class: Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber tags: - { name: event_subscriber } - arguments: ['@jsonapi.serializer', '%serializer.formats%'] - - # We want the 'api_json' format to not be supported in the REST module, so we - # cannot register its encoder with the Serialization module. Hence we have an - # encoder without the 'encoder' tag and 'format' property. But that also - # means we cannot reuse the @serializer service. So we define our own - # serializer service. But we still do want to reuse the generic normalizers - # from the Serialization module. So we inject all normalizers just like the - # default @serializer service does. Only appropriate normalizers are called - # thanks to the supportsNormalization() API method. - # @see \Drupal\jsonapi\DependencyInjection\Compiler\RegisterNormalizerClassesCompilerPass - # @see \Drupal\jsonapi\JsonapiServiceProvider::register() - # @see \Drupal\Tests\jsonapi\Functional\RestJsonApiUnsupported - # @see \Symfony\Component\Serializer\Normalizer\NormalizerInterface::supportsNormalization - jsonapi.serializer: - class: Symfony\Component\Serializer\Serializer - arguments: [{ }, ['@serializer.encoder.jsonapi']] - serializer.encoder.jsonapi: - class: Drupal\jsonapi\Encoder\JsonEncoder + arguments: ['@serializer', '%serializer.formats%'] + + # Event subscribers. + jsonapi.resource_response.subscriber: + class: Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber + tags: + - { name: event_subscriber } - arguments: ['@jsonapi.serializer', '@renderer', '@current_route_match'] ++ arguments: ['@serializer', '@renderer', '@current_route_match']