I want to change from the default em to an em called 'ps'. The configuration is correct and in the controller I can simply type $this->getManager('ps')->getConnection('ps');
.
However I want to create a service with dependency injection which also needs to access this connection.
<?php
namespace AppBundle\Service;
use Doctrine\ORM\EntityManagerInterface;
class HilaService
{
private $entityManager;
private $connection;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
$this->connection = $entityManager->getConnection('ps');
}
public function getCategories(){
$query = $this->connection->query(
'SQL ....'
);
$r = $query->execute();
}
}
As I can nowhere select the Entity Manager 'ps' it can't also load the connection 'ps', which results in an error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ps_xxx' doesn't exist
Can I somehow pass an argument to the injection? Or Inject somewhat of a 'parent object' to then call ->getManager()
?