Tuesday, 15 June 2010

symfony2 - Call to undefined method Doctrine\Bundle\DoctrineBundle\Registry::persist() -



symfony2 - Call to undefined method Doctrine\Bundle\DoctrineBundle\Registry::persist() -

i upgraded 1 of projects symfony 2.0.x 2.1.x

everything works fine, when seek persist entity in service, php throws error:

call undefined method doctrine\bundle\doctrinebundle\registry::persist()

in controllers, works fine. fetching objects db in service works, no phone call ->persist($entity).

this service definition:

registration_form: class: knowhow\eregistration\backendbundle\service\registrationformservice arguments: [ @doctrine ]

and class:

class registrationformservice { /** @var $em \doctrine\orm\entitymanager */ private $em; /** * ctor. * * @param $doctrine */ public function __construct($doctrine) { $this->em = $doctrine; } }

this okay, when seek thi $this->em->persist($entity) error gets thrown.

i have no thought what's going on there.

you have inject @doctrine.orm.entity_manager you're trying do

registration_form: class: knowhow\eregistration\backendbundle\service\registrationformservice arguments: [ @doctrine ] ----^ (isn't good)

modify to

registration_form: class: knowhow\eregistration\backendbundle\service\registrationformservice arguments: [ @doctrine.orm.entity_manager ]

alternatively, have utilize somthing (in constructor)

public function __construct(doctrine $doctrine) { $this->em = $doctrine->getentitymanager(); }

as cyprian suggest, i'll add together type of $doctrine variable type checking. don't know if doctrine right class, suppose is

i suggest inject entity_manager if don't need whole doctrine vendor

symfony2 doctrine2 symfony-2.1

No comments:

Post a Comment