Skip to content

Fixing services.yaml #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phauthentic/problem-details-symfony-bundle",
"type": "library",
"type": "symfony-bundle",
"description": "Symfony bundle for the Problem Details for HTTP APIs RFC",
"require": {
"php": "^8.2",
Expand Down
17 changes: 11 additions & 6 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ services:
arguments:
$validationErrorsBuilder: '@Phauthentic\Symfony\ProblemDetails\Validation\ValidationErrorsBuilder'
$problemDetailsResponseFactory: '@Phauthentic\Symfony\ProblemDetails\FromExceptionEventFactoryInterface'
tags:
- { name: 'exception.converter' }

Phauthentic\Symfony\ProblemDetails\ExceptionConversion\HttpExceptionConverter:
arguments:
$problemDetailsFactory: '@Phauthentic\Symfony\ProblemDetails\ProblemDetailsFactoryInterface'
tags:
- { name: 'exception.converter' }

Phauthentic\Symfony\ProblemDetails\ExceptionConversion\GenericExceptionConverter:
tags:
- { name: 'exception.converter' }

Phauthentic\Symfony\ProblemDetails\ExceptionConversion\ThrowableToProblemDetailsKernelListener:
Phauthentic\Symfony\ProblemDetails\ThrowableToProblemDetailsKernelListener:
arguments:
$exceptionConverters:
- '@Phauthentic\Symfony\ProblemDetails\ExceptionConversion\ValidationFailedExceptionConverter'
- '@Phauthentic\Symfony\ProblemDetails\ExceptionConversion\HttpExceptionConverter'
- '@Phauthentic\Symfony\ProblemDetails\ExceptionConversion\ThrowableToProblemDetailsKernelListener'
$exceptionConverters: !tagged_iterator exception.converter
tags:
- { name: 'kernel.event_listener', event: 'kernel.exception', priority: 0 }
- { name: 'kernel.event_listener', event: 'kernel.exception', priority: 0 }
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @link https://www.rfc-editor.org/rfc/rfc9457.html
*/
class GenericThrowableConverter implements ExceptionConverterInterface
class GenericExceptionConverter implements ExceptionConverterInterface
{
/**
* @param ProblemDetailsFactoryInterface $problemDetailsFactory
Expand Down
2 changes: 1 addition & 1 deletion src/ThrowableToProblemDetailsKernelListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ThrowableToProblemDetailsKernelListener
* @param array<ExceptionConverterInterface> $exceptionConverters
*/
public function __construct(
protected array $exceptionConverters = []
protected iterable $exceptionConverters = []
) {
if (empty($this->exceptionConverters)) {
throw new InvalidArgumentException('At least one converter must be provided');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Phauthentic\Symfony\ProblemDetails\Tests\Unit\ExceptionConversion;

use Exception;
use Phauthentic\Symfony\ProblemDetails\ExceptionConversion\GenericThrowableConverter;
use Phauthentic\Symfony\ProblemDetails\ExceptionConversion\GenericExceptionConverter;
use Phauthentic\Symfony\ProblemDetails\ExceptionConversion\HttpExceptionConverter;
use Phauthentic\Symfony\ProblemDetails\ProblemDetailsFactory;
use Phauthentic\Symfony\ProblemDetails\ProblemDetailsResponse;
Expand All @@ -24,7 +24,7 @@ public function setUp(): void
{
parent::setUp();

$this->converter = new GenericThrowableConverter(
$this->converter = new GenericExceptionConverter(
problemDetailsFactory: new ProblemDetailsFactory()
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/ThrowableToProblemDetailsKernelListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Exception;
use InvalidArgumentException;
use Phauthentic\Symfony\ProblemDetails\ExceptionConversion\GenericThrowableConverter;
use Phauthentic\Symfony\ProblemDetails\ExceptionConversion\GenericExceptionConverter;
use Phauthentic\Symfony\ProblemDetails\ProblemDetailsFactory;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
Expand Down Expand Up @@ -45,7 +45,7 @@ public function testOnKernelException(string $environment, bool $shouldHaveTrace

$listener = new ThrowableToProblemDetailsKernelListener(
[
new GenericThrowableConverter(new ProblemDetailsFactory(), $environment),
new GenericExceptionConverter(new ProblemDetailsFactory(), $environment),
]
);

Expand Down