From 4f05e526210415d6dcdf8979527318a7adc0db2c Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Tue, 17 Sep 2019 11:45:11 +0100
Subject: [PATCH] Issue #3055832 by BR0kEN, Wim Leers: Remove
 ResourceResponseValidator's unused $serializer property/service dependency

---
 core/modules/jsonapi/jsonapi.services.yml           |  2 +-
 .../EventSubscriber/ResourceResponseValidator.php   | 13 +------------
 .../ResourceResponseValidatorTest.php               |  7 -------
 3 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/core/modules/jsonapi/jsonapi.services.yml b/core/modules/jsonapi/jsonapi.services.yml
index 5e293a75c21d..b5cf0ef1e90d 100644
--- a/core/modules/jsonapi/jsonapi.services.yml
+++ b/core/modules/jsonapi/jsonapi.services.yml
@@ -208,7 +208,7 @@ services:
       - { name: event_subscriber }
   jsonapi.resource_response_validator.subscriber:
     class: Drupal\jsonapi\EventSubscriber\ResourceResponseValidator
-    arguments: ['@jsonapi.serializer', '@logger.channel.jsonapi', '@module_handler', '@app.root']
+    arguments: ['@logger.channel.jsonapi', '@module_handler', '@app.root']
     calls:
       - [setValidator, []]
     tags:
diff --git a/core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php b/core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php
index 3382244520d5..1502a21910a3 100644
--- a/core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php
+++ b/core/modules/jsonapi/src/EventSubscriber/ResourceResponseValidator.php
@@ -11,7 +11,6 @@
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
 use Symfony\Component\HttpKernel\KernelEvents;
-use Symfony\Component\Serializer\SerializerInterface;
 
 /**
  * Response subscriber that validates a JSON:API response.
@@ -28,13 +27,6 @@
  */
 class ResourceResponseValidator implements EventSubscriberInterface {
 
-  /**
-   * The serializer.
-   *
-   * @var \Symfony\Component\Serializer\SerializerInterface
-   */
-  protected $serializer;
-
   /**
    * The JSON:API logger channel.
    *
@@ -68,8 +60,6 @@ class ResourceResponseValidator implements EventSubscriberInterface {
   /**
    * Constructs a ResourceResponseValidator object.
    *
-   * @param \Symfony\Component\Serializer\SerializerInterface $serializer
-   *   The serializer.
    * @param \Psr\Log\LoggerInterface $logger
    *   The JSON:API logger channel.
    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
@@ -77,8 +67,7 @@ class ResourceResponseValidator implements EventSubscriberInterface {
    * @param string $app_root
    *   The application's root file path.
    */
-  public function __construct(SerializerInterface $serializer, LoggerInterface $logger, ModuleHandlerInterface $module_handler, $app_root) {
-    $this->serializer = $serializer;
+  public function __construct(LoggerInterface $logger, ModuleHandlerInterface $module_handler, $app_root) {
     $this->logger = $logger;
     $this->moduleHandler = $module_handler;
     $this->appRoot = $app_root;
diff --git a/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php b/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
index 7e79c187fc0b..1746400ef3e3 100644
--- a/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
+++ b/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Tests\jsonapi\Unit\EventSubscriber;
 
-use Drupal\jsonapi\Encoder\JsonEncoder;
 use Drupal\jsonapi\EventSubscriber\ResourceResponseValidator;
 use Drupal\jsonapi\ResourceType\ResourceType;
 use Drupal\jsonapi\Routing\Routes;
@@ -15,7 +14,6 @@
 use Psr\Log\LoggerInterface;
 use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\Serializer\Serializer;
 
 /**
  * @coversDefaultClass \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator
@@ -47,12 +45,7 @@ public function setUp() {
     $module_path = dirname(dirname(dirname(dirname(__DIR__))));
     $module->getPath()->willReturn($module_path);
     $module_handler->getModule('jsonapi')->willReturn($module->reveal());
-    $encoders = [new JsonEncoder()];
-    if (class_exists(JsonSchemaEncoder::class)) {
-      $encoders[] = new JsonSchemaEncoder();
-    }
     $subscriber = new ResourceResponseValidator(
-      new Serializer([], $encoders),
       $this->prophesize(LoggerInterface::class)->reveal(),
       $module_handler->reveal(),
       ''
-- 
GitLab