[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/tests/cases/ -> WactTestTemplateLocator.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  require_once('limb/wact/src/locator/WactTemplateLocator.interface.php');
  11  
  12  class WactTestTemplateLocator implements WactTemplateLocator
  13  {
  14    /**
  15     * @var WactTemplateConfig
  16     */
  17    protected $config;
  18  
  19    protected $templates = array();
  20    protected $file_names = array();
  21  
  22    public function __construct($config)
  23    {
  24      $this->config = $config;
  25    }
  26  
  27    public function locateCompiledTemplate($file_name)
  28    {
  29      $file_path = $this->file_names[$file_name];
  30      return $this->config->getCacheDir(). '/' . $file_path . '.php';
  31    }
  32  
  33    public function registerTestingTemplate($file_path, $template, $file_name = '')
  34    {
  35      if(!$file_name)
  36        $file_name = $file_path;
  37  
  38      $this->file_names[$file_name] = $file_path;
  39      $this->templates[$file_path] = $template;
  40    }
  41  
  42    public function locateSourceTemplate($file_name)
  43    {
  44      if (isset($this->file_names[$file_name]))
  45        return $this->file_names[$file_name];
  46    }
  47  
  48    public function readTemplateFile($file_path)
  49    {
  50      if (isset($this->templates[$file_path]))
  51        return $this->templates[$file_path];
  52    }
  53  
  54    public function clearTestingTemplates()
  55    {
  56      foreach(array_keys($this->templates) as $file_name)
  57      {
  58        $compiled = $this->config->getCacheDir().'/'.$file_name.'.php';
  59        if(file_exists($compiled))
  60          unlink($compiled);
  61      }
  62      clearstatcache();
  63  
  64      $this->templates = array();
  65    }
  66  }
  67  ?>


Generated: Mon Dec 1 03:56:46 2008 Cross-referenced by PHPXref 0.7