Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF][Symfony][Symfony2]FOSUserBundle - nie chce mi pokazać formularza do logowania
twojastara
post
Post #1





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 25.11.2014

Ostrzeżenie: (10%)
X----


exception o treści Unable to find Mountain entity pochodzący z akcji showAction($id) z tego kontrolera z lini 115

  1. <?php
  2.  
  3. namespace My\BackendBundle\Controller;
  4.  
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  10. use My\BackendBundle\Entity\Mountain;
  11. use My\BackendBundle\Form\MountainType;
  12.  
  13. /**
  14.  * Mountain controller.
  15.  *
  16.  */
  17. class MountainController extends Controller
  18. {
  19.  
  20. /**
  21.   * Lists all Mountain entities.
  22.   *
  23.   * @Route("/", name="mountain")
  24.   * @Method("GET")
  25.   * @Template()
  26.   */
  27. public function indexAction()
  28. {
  29. $em = $this->getDoctrine()->getManager();
  30.  
  31. $entities = $em->getRepository('MyBackendBundle:Mountain')->findAll();
  32.  
  33. return array(
  34. 'entities' => $entities,
  35. );
  36. }
  37. /**
  38.   * Creates a new Mountain entity.
  39.   *
  40.   * @Route("/", name="mountain_create")
  41.   * @Method("POST")
  42.   * @Template("MyBackendBundle:Mountain:new.html.twig")
  43.   */
  44. public function createAction(Request $request)
  45. {
  46. $entity = new Mountain();
  47. $form = $this->createCreateForm($entity);
  48. $form->handleRequest($request);
  49.  
  50. if ($form->isValid()) {
  51. $em = $this->getDoctrine()->getManager();
  52. $em->persist($entity);
  53. $em->flush();
  54.  
  55. return $this->redirect($this->generateUrl('mountain_show', array('id' => $entity->getId())));
  56. }
  57.  
  58. return array(
  59. 'entity' => $entity,
  60. 'form' => $form->createView(),
  61. );
  62. }
  63.  
  64. /**
  65.   * Creates a form to create a Mountain entity.
  66.   *
  67.   * @param Mountain $entity The entity
  68.   *
  69.   * @return \Symfony\Component\Form\Form The form
  70.   */
  71. private function createCreateForm(Mountain $entity)
  72. {
  73. $form = $this->createForm(new MountainType(), $entity, array(
  74. 'action' => $this->generateUrl('mountain_create'),
  75. 'method' => 'POST',
  76. ));
  77.  
  78. $form->add('submit', 'submit', array('label' => 'Create'));
  79.  
  80. return $form;
  81. }
  82.  
  83. /**
  84.   * Displays a form to create a new Mountain entity.
  85.   *
  86.   * @Route("/new", name="mountain_new")
  87.   * @Method("GET")
  88.   * @Template()
  89.   */
  90. public function newAction()
  91. {
  92. $entity = new Mountain();
  93. $form = $this->createCreateForm($entity);
  94.  
  95. return array(
  96. 'entity' => $entity,
  97. 'form' => $form->createView(),
  98. );
  99. }
  100.  
  101. /**
  102.   * Finds and displays a Mountain entity.
  103.   *
  104.   * @Route("/{id}", name="mountain_show")
  105.   * @Method("GET")
  106.   * @Template()
  107.   */
  108. public function showAction($id)
  109. {
  110. $em = $this->getDoctrine()->getManager();
  111.  
  112. $entity = $em->getRepository('MyBackendBundle:Mountain')->find($id);
  113.  
  114. if (!$entity) {
  115. throw $this->createNotFoundException('Unable to find Mountain entity.');
  116. }
  117.  
  118. $deleteForm = $this->createDeleteForm($id);
  119.  
  120. return array(
  121. 'entity' => $entity,
  122. 'delete_form' => $deleteForm->createView(),
  123. );
  124. }
  125.  
  126.  
  127. }
  128.  

pojawia się po tym gdy do aplikacji dodałem FOSUserBundle razem z jego klasami i zmianami w plikach conf

  1.  
  2. #\app\config\routing.yml
  3. MyBackendBundle:
  4. resource: "@MyBackendBundle/Controller/"
  5. type: annotation
  6. prefix: /
  7.  
  8. fos_user_security:
  9. resource: "@FOSUserBundle/Resources/config/routing/security.xml"
  10.  


  1. #\app\config\security.yml
  2. security:
  3. providers:
  4. fos_userbundle:
  5. id: fos_user.user_manager
  6.  
  7. encoders:
  8. FOS\UserBundle\Model\UserInterface: sha512
  9.  
  10. firewalls:
  11. main:
  12. pattern: ^/
  13. logout: true
  14. anonymous: true
  15. form_login:
  16. provider: fos_userbundle
  17. csrf_provider: form.csrf_provider
  18. login_path: /login
  19. use_forward: false
  20. check_path: /login_check
  21. post_only: true
  22. always_use_default_target_path: false
  23. default_target_path: /
  24. target_path_parameter: _target_path
  25. use_referer: false
  26. failure_path: null
  27. failure_forward: false
  28. username_parameter: _username
  29. password_parameter: _password
  30. csrf_parameter: _csrf_token
  31. intention: authenticate
  32.  
  33. access_control:
  34. - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
  35. - { path: ^/, role: ROLE_SUPER_ADMIN }
  36.  


Ten post edytował twojastara 21.01.2015, 23:14:37
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 20:37