Created
June 9, 2011 10:10
-
-
Save rande/1016464 to your computer and use it in GitHub Desktop.
PageBundle with Page's Snapshot
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 PageController extends Controller | |
{ | |
public function catchAllAction() | |
{ | |
$pathInfo = $this->get('request')->getPathInfo(); | |
$snapshotManager = $this->get('sonata.page.manager.snapshot'); | |
$snapshot = $snapshotManager->findOneBy(array( | |
'slug' => $pathInfo, | |
'enabled' => true | |
)); | |
if (!$snapshot) { | |
throw new NotFoundHttpException('The current page does not exist!'); | |
} | |
$page = $this->get('sonata.page.manager.page')->loadSnapshot($snapshot); | |
$manager = $this->get('sonata.page.manager'); | |
$manager->setCurrentPage($page); | |
return $manager->renderPage($page); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment