I’m new on symfony and need help
When i’m running ‘console debug:event’ I got this error message :
AppEventListenerReservationEventSubscriber::__construct(): Argument #3 ($id) must be of type int, string given, called in /Applica
tions/MAMP/htdocs/E-STock/E-STock_v6/var/cache/dev/ContainerTiaj2qn/getReservationEventSubscriberService.php on line 22
The problem is that I don’t understand how to fix it.
Even I’m not sur to really understand the problem ^^
this is my code :
ReservationEventSubscriber :
class ReservationEventSubscriber implements EventSubscriberInterface
{
private $manager;
private int $id;
public function __construct(EntityManagerInterface $manager, TokenStorageInterface $tokenStorage, int $pieceId)
{
$this->manager = $manager;
$this->tokenStorage = $tokenStorage;
$this->id = $pieceId;
}
I’ve bind my “pieceId” here on ‘service.yaml’
parameters:
id: 'secret'
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
int $pieceId: '%id%'
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'