Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyController extends ActionController
- {
- /* ... */
- public feedAction()
- {
- $this->getEvent()->setParam('disableLayout', true);
- }
- /* ... */
- }
- class View\Listener
- {
- public function attach(EventCollection $events)
- {
- $this->listeners[] = $events->attach('dispatch.error', array($this, 'renderError'));
- $this->listeners[] = $events->attach('dispatch', array($this, 'render404'), -80);
- $this->listeners[] = $events->attach('dispatch', array($this, 'setLayout'), -999);
- $this->listeners[] = $events->attach('dispatch', array($this, 'renderLayout'), -1000);
- }
- /**
- * Make some decisions regarding the layout just before redering it
- *
- * @param MvcEvent $e
- */
- public function setLayout(MvcEvent $e)
- {
- if ($e->getParam('layout')) {
- $this->layoutScript = $e->getParam('layout');
- } elseif ($e->getParam('layout') === false) {
- $e->stopPropagation();
- $response = $e->getResponse();
- if (!$response) {
- $response = new Response();
- $e->setResponse($response);
- }
- $response->setContent($e->getResult());
- return $response;
- }
- }
- }
Add Comment
Please, Sign In to add comment