Issue #3055832 by BR0kEN, Wim Leers: Remove ResourceResponseValidator's unused $serializer property/service dependency

merge-requests/55/head
catch 2019-09-17 11:45:11 +01:00
parent 17bd9ce08f
commit 4f05e52621
3 changed files with 2 additions and 20 deletions

View File

@ -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:

View File

@ -11,7 +11,6 @@ use Symfony\Component\HttpFoundation\Request;
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 @@ use Symfony\Component\Serializer\SerializerInterface;
*/
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;

View File

@ -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 Prophecy\Argument;
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 @@ class ResourceResponseValidatorTest extends UnitTestCase {
$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(),
''