Controller.php 649 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Typemill\Controllers;
  3. /* Use the slim-container */
  4. use Interop\Container\ContainerInterface;
  5. use Typemill\Events\OnPageReady;
  6. abstract class Controller
  7. {
  8. protected $c;
  9. public function __construct(ContainerInterface $c)
  10. {
  11. $this->c = $c;
  12. }
  13. protected function render($response, $route, $data)
  14. {
  15. $data = $this->c->dispatcher->dispatch('onPageReady', new OnPageReady($data))->getData();
  16. unset($_SESSION['old']);
  17. return $this->c->view->render($response, $route, $data);
  18. }
  19. protected function render404($response, $data = NULL)
  20. {
  21. return $this->c->view->render($response->withStatus(404), '/404.twig', $data);
  22. }
  23. }