1 | <?php |
||
2 | declare(strict_types = 1); |
||
3 | /** |
||
4 | * /src/EventSubscriber/ResponseSubscriber.php |
||
5 | * |
||
6 | * @author TLe, Tarmo Leppänen <[email protected]> |
||
7 | */ |
||
8 | |||
9 | namespace App\EventSubscriber; |
||
10 | |||
11 | use App\Service\Version; |
||
0 ignored issues
–
show
|
|||
12 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||
13 | use Symfony\Component\HttpKernel\Event\ResponseEvent; |
||
14 | |||
15 | /** |
||
16 | * Class ResponseSubscriber |
||
17 | * |
||
18 | * @package App\EventSubscriber |
||
19 | * @author TLe, Tarmo Leppänen <[email protected]> |
||
20 | */ |
||
21 | class ResponseSubscriber implements EventSubscriberInterface |
||
22 | { |
||
23 | 597 | public function __construct( |
|
24 | private readonly Version $version, |
||
25 | ) { |
||
26 | 597 | } |
|
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 1 | public static function getSubscribedEvents(): array |
|
32 | { |
||
33 | 1 | return [ |
|
34 | 1 | ResponseEvent::class => [ |
|
35 | 1 | 'onKernelResponse', |
|
36 | 1 | 10, |
|
37 | 1 | ], |
|
38 | 1 | ]; |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * Subscriber method to attach API version to every response. |
||
43 | */ |
||
44 | 597 | public function onKernelResponse(ResponseEvent $event): void |
|
45 | { |
||
46 | // Attach new header |
||
47 | 597 | $event->getResponse()->headers->add([ |
|
48 | 597 | 'X-API-VERSION' => $this->version->get(), |
|
49 | 597 | ]); |
|
50 | } |
||
51 | } |
||
52 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths