For a project that I'm working on, using Symfony which I'm quite new to, I am trying to create an object of a class that uses Dependency Injection but also needs some custom parameters.
Now let's say I have a Command:
<?php
class ServerCommand extends Command {
public function __construct(Server $server) {
$this->server = $server;
}
protected function execute(InputInterface $input, OutputInterface $output) {
...
}
}
And a Server class:
<?php
class Server {
public function __construct(MessageManager $messageManager, InputInterface $input, OutputInterface $output) {
...
}
}
Now, the Server class is injected into the Command class and the MessageManager class is injected into the Server class.
The problem that I'm having is getting the $input and $ouput variables in the Command class into the constructor of the Server class.
And to make it even more difficult, I also want the $input and $output variables accessible in the MessageManager class.
Is this possible, and if so, how do I achieve this?