Issue #3055832 by BR0kEN, Wim Leers: Remove ResourceResponseValidator's unused $serializer property/service dependency
parent
17bd9ce08f
commit
4f05e52621
|
@ -208,7 +208,7 @@ services:
|
||||||
- { name: event_subscriber }
|
- { name: event_subscriber }
|
||||||
jsonapi.resource_response_validator.subscriber:
|
jsonapi.resource_response_validator.subscriber:
|
||||||
class: Drupal\jsonapi\EventSubscriber\ResourceResponseValidator
|
class: Drupal\jsonapi\EventSubscriber\ResourceResponseValidator
|
||||||
arguments: ['@jsonapi.serializer', '@logger.channel.jsonapi', '@module_handler', '@app.root']
|
arguments: ['@logger.channel.jsonapi', '@module_handler', '@app.root']
|
||||||
calls:
|
calls:
|
||||||
- [setValidator, []]
|
- [setValidator, []]
|
||||||
tags:
|
tags:
|
||||||
|
|
|
@ -11,7 +11,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Response subscriber that validates a JSON:API response.
|
* Response subscriber that validates a JSON:API response.
|
||||||
|
@ -28,13 +27,6 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||||
*/
|
*/
|
||||||
class ResourceResponseValidator implements EventSubscriberInterface {
|
class ResourceResponseValidator implements EventSubscriberInterface {
|
||||||
|
|
||||||
/**
|
|
||||||
* The serializer.
|
|
||||||
*
|
|
||||||
* @var \Symfony\Component\Serializer\SerializerInterface
|
|
||||||
*/
|
|
||||||
protected $serializer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The JSON:API logger channel.
|
* The JSON:API logger channel.
|
||||||
*
|
*
|
||||||
|
@ -68,8 +60,6 @@ class ResourceResponseValidator implements EventSubscriberInterface {
|
||||||
/**
|
/**
|
||||||
* Constructs a ResourceResponseValidator object.
|
* Constructs a ResourceResponseValidator object.
|
||||||
*
|
*
|
||||||
* @param \Symfony\Component\Serializer\SerializerInterface $serializer
|
|
||||||
* The serializer.
|
|
||||||
* @param \Psr\Log\LoggerInterface $logger
|
* @param \Psr\Log\LoggerInterface $logger
|
||||||
* The JSON:API logger channel.
|
* The JSON:API logger channel.
|
||||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||||
|
@ -77,8 +67,7 @@ class ResourceResponseValidator implements EventSubscriberInterface {
|
||||||
* @param string $app_root
|
* @param string $app_root
|
||||||
* The application's root file path.
|
* The application's root file path.
|
||||||
*/
|
*/
|
||||||
public function __construct(SerializerInterface $serializer, LoggerInterface $logger, ModuleHandlerInterface $module_handler, $app_root) {
|
public function __construct(LoggerInterface $logger, ModuleHandlerInterface $module_handler, $app_root) {
|
||||||
$this->serializer = $serializer;
|
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->moduleHandler = $module_handler;
|
$this->moduleHandler = $module_handler;
|
||||||
$this->appRoot = $app_root;
|
$this->appRoot = $app_root;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Drupal\Tests\jsonapi\Unit\EventSubscriber;
|
namespace Drupal\Tests\jsonapi\Unit\EventSubscriber;
|
||||||
|
|
||||||
use Drupal\jsonapi\Encoder\JsonEncoder;
|
|
||||||
use Drupal\jsonapi\EventSubscriber\ResourceResponseValidator;
|
use Drupal\jsonapi\EventSubscriber\ResourceResponseValidator;
|
||||||
use Drupal\jsonapi\ResourceType\ResourceType;
|
use Drupal\jsonapi\ResourceType\ResourceType;
|
||||||
use Drupal\jsonapi\Routing\Routes;
|
use Drupal\jsonapi\Routing\Routes;
|
||||||
|
@ -15,7 +14,6 @@ use Prophecy\Argument;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Serializer\Serializer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @coversDefaultClass \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator
|
* @coversDefaultClass \Drupal\jsonapi\EventSubscriber\ResourceResponseValidator
|
||||||
|
@ -47,12 +45,7 @@ class ResourceResponseValidatorTest extends UnitTestCase {
|
||||||
$module_path = dirname(dirname(dirname(dirname(__DIR__))));
|
$module_path = dirname(dirname(dirname(dirname(__DIR__))));
|
||||||
$module->getPath()->willReturn($module_path);
|
$module->getPath()->willReturn($module_path);
|
||||||
$module_handler->getModule('jsonapi')->willReturn($module->reveal());
|
$module_handler->getModule('jsonapi')->willReturn($module->reveal());
|
||||||
$encoders = [new JsonEncoder()];
|
|
||||||
if (class_exists(JsonSchemaEncoder::class)) {
|
|
||||||
$encoders[] = new JsonSchemaEncoder();
|
|
||||||
}
|
|
||||||
$subscriber = new ResourceResponseValidator(
|
$subscriber = new ResourceResponseValidator(
|
||||||
new Serializer([], $encoders),
|
|
||||||
$this->prophesize(LoggerInterface::class)->reveal(),
|
$this->prophesize(LoggerInterface::class)->reveal(),
|
||||||
$module_handler->reveal(),
|
$module_handler->reveal(),
|
||||||
''
|
''
|
||||||
|
|
Loading…
Reference in New Issue