FriendsOfSymfony/FOSUserBundle — Issue #548: FOSUserBundle with relation another entity 
Author: Raulken
Created: 2012-02-22 14:14:44+00:00
State: open

I related my acme / userbundle with another entity, now I need to write to the database for userbundle and for the other entity at the same time, so I overwrote the controller RegistrationController.php and I added these lines:
namespace Acme\UserBundle\Controller;

use Symfony\Component\HttpFoundation\RedirectResponse;
use FOS\UserBundle\Controller\RegistrationController as BaseController;
use Acme\TestBundle\Entity\Test;

/+++++++/
if ($process) {
$user = $form->getData();
$test = new Test();
$test->setUser($user);
$test->setName('Name test');

$em = $this->getDoctrine()->getEntityManager();<-----------------------LINE 25
$em->persist($test);
$em->flush();
/*****************************************************
* Add new functionality (e.g. log the registration) *
*****************************************************/
/+++++++/

Fatal error: Call to undefined method Acme\UserBundle\Controller\RegistrationController::getDoctrine() in /home/marcello/Progetti/Symfony/src/Acme/UserBundle/Controller/RegistrationController.php on line 25

How can i write into database in contemporany with registration fosuserbundle?thx