Controller.php 596 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Core;
  3. abstract class Controller
  4. {
  5. protected $data;
  6. protected $controller_name;
  7. protected $view_name;
  8. protected $template_dir;
  9. function assign($key, $value)
  10. {
  11. $this->data[$key] = $value;
  12. }
  13. function display($file = '')
  14. {
  15. $this->template_dir = Application::getInstance()->base_dir.'/Views';
  16. if (empty($file))
  17. {
  18. $file = strtolower($this->controller_name).'/'.$this->view_name.'.php';
  19. }
  20. $path = $this->template_dir.'/'.$file;
  21. extract($this->data);
  22. include $path;
  23. }
  24. }