【发布时间】:2014-04-02 12:39:58
【问题描述】:
这是发布路由的路由信息:
cacic_uorg_type_excluir:
pattern: /uorg/type/excluir/{idUorgType}
defaults: { _controller: CacicCommonBundle:UorgType:excluir, idUorgType: null}
requirements:
idUorgType: \d+
这是我的控制器
public function excluirAction( $idUorg, Request $request )
{
if ( ! $request->isXmlHttpRequest() )
throw $this->createNotFoundException( 'page not found' );
$uorgType = $this->getDoctrine()->getRepository('CacicCommonBundle:TipoUorg')->find( $request->get('id') );
if ( ! $uorgType )
throw $this->createNotFoundException( 'UORG nor found' );
$em = $this->getDoctrine()->getManager();
$em->remove( $uorgType );
$em->flush();
$response = new Response( json_encode( array('status' => 'ok') ) );
$response->headers->set('Content-Type', 'application/json');
return $response;
}
但我总是出错
Controller "Cacic\CommonBundle\Controller\UorgTypeController::excluirAction()" requires that you provide a value for the "$idUorg" argument (because there is no default value or because there is a non optional argument after this one).
【问题讨论】:
标签: php symfony controller routing