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

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

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -