I created symfony service as described here: Symfony2: get Doctrine in a generic PHP class
Service.yml
app.lib.helpers:
class: AppBundle\Lib\Helpers
arguments: [doctrine.orm.entity_manager]
Class Helpers
class Helpers
{
protected $em;
public function __construct($entityManager)
{
$this->em = $entityManager;
}
public function checkStatuses()
{
$orderId = $this->em->getRepository('AppBundle:Orders')->findAll();
}
}
In controller action
$helper = $this->get('app.lib.helpers');
$helper->checkStatuses();
But im getting error:
Error: Call to a member function getRepository() on string
What causes that problem?