I am trying to inject an array to Event Subscriber, but I also inject an other repository so I don’t know how this will work:
Here’s what I am trying:
services.yaml
PathToMyEventSubscriberTerminateSubscriber:
arguments:
- { param1: 'myvalue', param2: 'myvalue2' }
TerminateSubscriber.php:
private Repository $repo;
/** @var array<string, string> */
private array $config;
public function __construct(Repository $repo, array $config = [])
{
$this->repo = $repo;
$this->config = $config;
}
It says that the first parameter should be an instance of the Repo, array given.
But if I switch the parameters it says "optional parameter given before required"
Source: Symfony Questions
Was this helpful?
0 / 0