2
1-有可能使用redirectToRoute()傳遞對象嗎?如何將參數傳遞給函數並更改路由
$ccp = new Ccp();
return ($this->redirectToRoute("_indexAccountCcpClient",array('ccp'=>$ccp)));
這是我的陽明路由:
_indexCcpClient:
path: /index
defaults: { _controller: EgovPosteBundle:Ccp:indexCcp }
_indexAccountCcpClient:
path: /account/index
defaults: { _controller: EgovPosteBundle:Ccp:indexAccountCcp }
我控制器
public function indexCcpAction()
{
$demanceCCP = new DemandeCCP();
$ccp = new Ccp();
$formDemanceCCP = $this->createForm(new DemandeCcpType(), $demanceCCP);
$formCcp = $this->createForm(new LoginCcpType(), $ccp);
$formCcp->handleRequest($this->get('request'));
$formDemanceCCP->handleRequest($this->get('request'));
$em = $this->getDoctrine()->getManager();
if ($this->get("request")->getMethod() == "POST") {
if ($this->get("request")->request->has("DemandeCcpType")) {
$demanceCCP = $formDemanceCCP->getData();
$em->persist($demanceCCP);
$em->flush();
}
if ($this->get("request")->request->has("LoginCcpType")) {
$ccp = $formCcp->getData();
$dbCcp = $this->getDoctrine()->getRepository('EgovCoreBundle:Ccp')
->findOneBy(array('numCompte' => $ccp->getNumCompte(), 'mdp' => $ccp->getMdp()));
if (!$dbCcp) {
throw $this->createNotFoundException('No Data found for id ');
} else {
self::indexAccountCcpAction($ccp);
//return ($this->redirectToRoute("_indexAccountCcpClient",array('ccp'=>$ccp)));
}
}
}
return $this->render('@EgovPoste/Ccp/indexCcp.html.twig',
array('formDemandeCcp' => $formDemanceCCP->createView(),
'formLogin' => $formCcp->createView())
);
}
public function indexAccountCcpAction(Ccp $ccp)
{
//echo ($ccp->getNumCompte());
return $this->render('EgovPosteBundle:Ccp:indexAccountCcp.html.twig', array('ccp' => $ccp));
}
所以我probleme是我怎麼能叫indexAccountCcpAction(CCP $ CCP)功能和修改路由路徑/ account/index
在我的代碼中,它工作正常,但具有相同的路徑:/ index