00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00016 class ModelAndView
00017 {
00018 private $model = null;
00019
00020 private $view = null;
00021
00025 public static function create()
00026 {
00027 return new self;
00028 }
00029
00030 public function __construct()
00031 {
00032 $this->model = new Model();
00033 }
00034
00038 public function getModel()
00039 {
00040 return $this->model;
00041 }
00042
00046 public function setModel(Model $model)
00047 {
00048 $this->model = $model;
00049
00050 return $this;
00051 }
00052
00053 public function getView()
00054 {
00055 return $this->view;
00056 }
00057
00061 public function setView($view)
00062 {
00063 Assert::isTrue(
00064 ($view instanceof View) || is_string($view),
00065 'do not know, what to do with such view'
00066 );
00067
00068 $this->view = $view;
00069
00070 return $this;
00071 }
00072
00073 public function viewIsRedirect()
00074 {
00075 return
00076 ($this->view instanceof RedirectView)
00077 || ($this->view instanceof RedirectToView)
00078 || (
00079 is_string($this->view)
00080 && strpos($this->view, 'redirect') === 0
00081 );
00082 }
00083
00084 public function viewIsNormal()
00085 {
00086 return (
00087 !$this->viewIsRedirect()
00088 && $this->view !== View::ERROR_VIEW
00089 );
00090 }
00091 }
00092 ?>