Thursday, November 29, 2018

php - Silex redirect from Twig template

First, I know this is a horrible thing to do and should be done in controller logic only, but what I'm trying to do is create a custom redirect tag in Twig that fires a Silex redirect.



I have a custom node that outputs the following into the doDisplay template:



return $this->getEnvironment()->getExtension('silex')->getApp()->redirect('/', 301);


Basically this gets the Twig environment and the extension I created which has a getApp method which returns the Silex $app variable, which contains the redirect method.




But this only returns Array() to the screen. Any suggestions?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...