php - Why is the controller executed twice (flashbag, redirectoroute)? -


i have 2 routes /alpha , /beta configured in yml. in alphaaction notice placed in flashbag , redirecttoroute occurs. in betaaction notice in flashbag read.

sometimes 2 notices when try /alpha in browser , 1 notice.

can explain happening, i'm doing wrong.

public function alphaaction() {   $this->get('session')->getflashbag()->add("notice",mt_rand());   return $this->redirecttoroute("beta"); }  public function betaaction() {   $notices= $this->get('session')->getflashbag()->get('notice');       return new response(implode($notices,", ")); } 

using add method reproduce issues described. can fixed using set method , not add (or setflash) method.

public function alphaaction() {   $this->get('session')->getflashbag()->set("notice",mt_rand());   return $this->redirecttoroute("beta"); }  public function betaaction() {   $notices= $this->get('session')->getflashbag()->get('notice');       return new response(implode($notices,", ")); } 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -