I am trying to getDoctrine () outside the controller. I created this service:
configurations / services.yml
services:
update_command:
class: project\projBundle\Command\Update
arguments: ['@doctrine.orm.entity_manager']
and in my application /config/config.yml
imports:
- { resource: "@projectprojBundle/Resources/config/services.yml" }
so is the class I want to use:
namespace project\projBundle\Command;
use Doctrine\ORM\EntityManager;
class Update {
protected $em;
public function __construct(EntityManager $em) {
$this->em = $em;
}
but every time I want to do this: ( Am I doing it right? )
$up = new Update();
I got this error:
Catchable Fatal Error: Argument 1 passed to ...\Update::__construct() must be an instance of Doctrine\ORM\EntityManager, none given, called in .../Update.php line 7
source
share