I need to implement a log-data that I want to persist to my DB while a user registers at my site.
This is what I tried with following steps:
http://symfony.com/doc/2.0/cookbook/bundles/inheritance.html
1.) I registered the FOSUserBundle as the "parent" of my Bundle
- Code: Select all
<?php
// src/My/MyBundle/MyMyBundle.php
namespace My\MyBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MyMyBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
2.) I set up a file with the same name located at my bundle's controller folder:
- Code: Select all
<?php
// src/My/MyBundle/Controller/RegistrationController.php
namespace My\MyBundle\Controller;
use FOS\UserBundle\Controller\RegistrationController as BaseController;
use My\MyBundle\Entity\Log;
class RegistrationController extends BaseController
{
public function registerAction()
{
$response = parent::registerAction();
// do custom stuff
$log = new Log();
$log->setData('testdata');
$em = $this->getDoctrine()
->getEntityManager();
$em->persist($log);
$em->flush();
return $response;
}
}
However, it seems like "my" (above) RegistrationController.php in my bundle doesn't get loaded at all (an echo doesn't show anything either).
How can I override the RegistrationController?
And also: I have some other ressources (template files) of the FOSUserBundle that I am currently overriding in the main app/ressources folder. Is that the best practice? Or is there a way to override them in my bundle folder as well (e.g. /src/My/MyBundle/ressources)?
Many thanks,
Mike
