Controller.php 624 B

1234567891011121314151617181920212223242526272829
  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. return $this->c->view->render($response, $route, $data);
  17. }
  18. protected function render404($response, $data = NULL)
  19. {
  20. return $this->c->view->render($response->withStatus(404), '/404.twig', $data);
  21. }
  22. }