Last active
April 12, 2016 11:01
-
-
Save jehaby/6c9cc193e08bbf35f5b9561abb42402d to your computer and use it in GitHub Desktop.
Static pages with Symfony
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SomeController extends Controller { | |
/** | |
* @Route("/speaker/{slug}", name="speaker") | |
*/ | |
public function speakerAction($slug) | |
{ | |
$pagesDirectory = $this->getParameter('kernel.root_dir') . '/Resources/pages/'; | |
$speakerInfo = include $pagesDirectory . $slug . '.php'; | |
if (empty($speakerInfo)) { | |
throw new NotFoundHttpException; | |
} | |
return $this->render('speaker.html.twig', $speakerInfo + ['slug' => $slug]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment