You can register this class as service and enter any other services in it. Suppose you have GenericClass.php as follows:
class GenericClass { public function __construct() {
You can register it as a service (usually in your kit Resources/config/service.yml|xml ) and enter the Doctrine entity administrator in it:
services: my_mailer: class: Path/To/GenericClass arguments: [doctrine.orm.entity_manager]
And he will try to add the entity administrator (default) of the GenericClass constructor. So you just need to add an argument:
public function __construct($entityManager) {
If you do not know what services are available in the DI container of your application, you can find out using the command line tool: php app/console container:debug and it will list all available services along with its aliases and classes.
source share