You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
758 B

<?php
namespace yii\twig;
/**
* Twig view file loader class
*
* @author dev-mraj <dev.meghraj@gmail.com>
* @version 1.0.0
*/
class TwigSimpleFileLoader implements \Twig_LoaderInterface {
/**
* Path to directory where all file exists
11 years ago
* @var string
*/
private $dir;
public function __construct($dir){
$this->dir=$dir;
}
public function isFresh($name, $time){
return filemtime($this->getFilePath($name))<=$time;
}
public function getSource($name){
return file_get_contents($this->getFilePath($name));
}
public function getCacheKey($name){
return $this->getFilePath($name);
}
protected function getFilePath($name){
return $this->dir.'/'.$name;
}
}