I have a class that depends on the connection to the database, something like this:
class Test { private $conn; public function __construct(Connection $conn) { $this->conn = $conn; } }
A service for this might look like this:
services: service.test: class: Test arguments: - ["@database_connection"]
Now I want to transfer my own service / connection object, which creates Connection at startup. But I cannot pass this as an argument, because it wants a Connection object, not a factory.
How can I best approach this?
I tried adding setConnection to the Test class, but it would be better to keep the current definition and maintenance intact.
source share