I have a class which is dependent on a DB connection, something like this:
class Test
{
private $conn;
public function __construct(Connection $conn) {
$this->conn = $conn;
}
}
The service for this could look like this:
services:
service.test:
class: Test
arguments:
- ["@database_connection"]
Now, I'd like to pass my own connection service / object that at startup creates a Connection
. But I can't pass it as an argument as it wants a Connection
object, not a factory.
How can I best approach this?
I've tried adding a setConnection
on the Test
class, but it would be nicer to keep the current definition and service intact.