Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
FOSUserBundle with relation another entity
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Francesco  
View profile  
 More options Feb 22 2012, 10:40 am
From: Francesco <voc.marce...@gmail.com>
Date: Wed, 22 Feb 2012 07:40:05 -0800 (PST)
Local: Wed, Feb 22 2012 10:40 am
Subject: FOSUserBundle with relation another entity
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan Weaver  
View profile  
 More options Feb 22 2012, 11:35 am
From: Ryan Weaver <weaverr...@gmail.com>
Date: Wed, 22 Feb 2012 10:35:11 -0600
Local: Wed, Feb 22 2012 11:35 am
Subject: Re: FOSUserBundle with relation another entity
Hi there!

The normal getDoctrine method is just a shortcut in the optional, but standard base controller class. The FOS controllers don't extend the base controller, so you just don't have access to those same shortcut methods.

The best thing to do is to take a look at the base Controller class inside symfony and see what each method actually does. For example, getDoctrine is equivalent to:

    $this->container->get('doctrine')

Good luck!

Ryan

On Feb 22, 2012, at 9:40 AM, Francesco <voc.marce...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Francesco  
View profile  
 More options Feb 24 2012, 3:26 am
From: Francesco <voc.marce...@gmail.com>
Date: Fri, 24 Feb 2012 00:26:57 -0800 (PST)
Local: Fri, Feb 24 2012 3:26 am
Subject: Re: FOSUserBundle with relation another entity
excuse me how I should do to save more data in another table, in
conjunction with user?

i must extend controller RegistrationController od fosuserbundle?
and i must insert the logic into this file?

I knew all logic, i must insert inside controller....
can u show me an pratical example?thx


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »