# PhpViewResolver.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
    00015     class PhpViewResolver implements ViewResolver
    00016     {
    00017         private $prefix     = null;
    00018         private $postfix    = null;
    00019
    00020         public function __construct($prefix = null, $postfix = null)
    00021         {
    00022             $this->prefix   = $prefix;
    00023             $this->postfix  = $postfix;
    00024         }
    00025
    00029         public static function create($prefix = null, $postfix = null)
    00030         {
    00031             return new self($prefix, $postfix);
    00032         }
    00033
    00037         public function resolveViewName($viewName)
    00038         {
    00039             return
    00040                 new SimplePhpView(
    00041                     $this->prefix.$viewName.$this->postfix,
    00042                     $this
    00043                 );
    00044         }
    00045
    00046         public function viewExists($viewName)
    00047         {
    00048             return is_readable($this->prefix.$viewName.$this->postfix);
    00049         }
    00050
    00051         public function getPrefix()
    00052         {
    00053             return $this->prefix;
    00054         }
    00055
    00059         public function setPrefix($prefix)
    00060         {
    00061             $this->prefix = $prefix;
    00062
    00063             return $this;
    00064         }
    00065
    00066         public function getPostfix()
    00067         {
    00068             return $this->postfix;
    00069         }
    00070
    00074         public function setPostfix($postfix)
    00075         {
    00076             $this->postfix = $postfix;
    00077
    00078             return $this;
    00079         }
    00080     }
    00081 ?>