ModelAndView.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2006-2007 by Anton E. Lebedevich                        *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 /* $Id: ModelAndView.class.php 4687 2007-12-09 18:57:18Z voxus $ */
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 ?>

Generated on Sun Dec 9 21:56:24 2007 for onPHP by  doxygen 1.5.4