exception o treści
Unable to find Mountain entity pochodzący z akcji showAction($id) z tego kontrolera z lini 115
<?php
namespace My\BackendBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use My\BackendBundle\Entity\Mountain;
use My\BackendBundle\Form\MountainType;
/**
* Mountain controller.
*
*/
class MountainController extends Controller
{
/**
* Lists all Mountain entities.
*
* @Route("/", name="mountain")
* @Method("GET")
* @Template()
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('MyBackendBundle:Mountain')->findAll();
'entities' => $entities,
);
}
/**
* Creates a new Mountain entity.
*
* @Route("/", name="mountain_create")
* @Method("POST")
* @Template("MyBackendBundle:Mountain:new.html.twig")
*/
public function createAction(Request $request)
{
$entity = new Mountain();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('mountain_show', array('id' => $entity->getId()))); }
'entity' => $entity,
'form' => $form->createView(),
);
}
/**
* Creates a form to create a Mountain entity.
*
* @param Mountain $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(Mountain $entity)
{
$form = $this->createForm(new MountainType
(), $entity, array( 'action' => $this->generateUrl('mountain_create'),
'method' => 'POST',
));
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
}
/**
* Displays a form to create a new Mountain entity.
*
* @Route("/new", name="mountain_new")
* @Method("GET")
* @Template()
*/
public function newAction()
{
$entity = new Mountain();
$form = $this->createCreateForm($entity);
'entity' => $entity,
'form' => $form->createView(),
);
}
/**
* Finds and displays a Mountain entity.
*
* @Route("/{id}", name="mountain_show")
* @Method("GET")
* @Template()
*/
public function showAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('MyBackendBundle:Mountain')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Mountain entity.');
}
$deleteForm = $this->createDeleteForm($id);
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
);
}
}
pojawia się po tym gdy do aplikacji dodałem
FOSUserBundle razem z jego klasami i zmianami w plikach conf
#\app\config\routing.yml
MyBackendBundle:
resource: "@MyBackendBundle/Controller/"
type: annotation
prefix: /
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
#\app\config\security.yml
security:
providers:
fos_userbundle:
id: fos_user.user_manager
encoders:
FOS\UserBundle\Model\UserInterface: sha512
firewalls:
main:
pattern: ^/
logout: true
anonymous: true
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: /login
use_forward: false
check_path: /login_check
post_only: true
always_use_default_target_path: false
default_target_path: /
target_path_parameter: _target_path
use_referer: false
failure_path: null
failure_forward: false
username_parameter: _username
password_parameter: _password
csrf_parameter: _csrf_token
intention: authenticate
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, role: ROLE_SUPER_ADMIN }
Ten post edytował twojastara 21.01.2015, 23:14:37