On est souvent ammené à vouloir surcharger un fichier d'un bundle pour le modifier et le personaliser.
dans cet exemple on va surcharger le bundle FOSUerBundle dans le nouveau bundle UserBundle:
- namespace Nw\UserBundle;
- use Symfony\Component\HttpKernel\Bundle\Bundle;
- class NwUserBundle extends Bundle
- {
- public function getParent()
- {
- return 'FOSUserBundle';
- }
- }
- namespace nw\UserBundle\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Symfony\Component\HttpFoundation\Response;
- use FOS\UserBundle\Controller\SecurityController as SecurityController;
- use nw\UserBundle\Entity\User;
- /**
- * Description of UserController
- *
- */
- class UserController extends SecurityController {
- public function LoginBisAction()
- {
- $csrfToken = $this->container->get('form.csrf_provider')->generateCsrfToken('authenticate');
- return $this->container->get('templating')->renderResponse('FOSUserBundle:Security:login_content.html.twig', array(
- 'last_username' => null,
- 'error' => null,
- 'csrf_token' => $csrfToken
- ));
- }
- public function createAction()
- {
- $roles = $this->get('security.roles')->getRoles();
- }
- }