cdfe8eaf |
<?php
namespace elanpl\L3;
class ViewEngine{
protected $viewengines; //registered view engines dictionary
public function __construct()
{
$this->viewengines = array();
}
|
1b8a151b |
public function register($fileExtension, $viewEngine, $config = null){
|
67797958 |
if(!class_exists($viewEngine,true)){
throw new \Exception("Class \"$viewEngine\" not found!");
}
|
cd60f809 |
if(!isset(class_implements($viewEngine, true)['elanpl\\L3\\IViewEngine'])){
|
cdfe8eaf |
throw new \Exception("Class \"$viewEngine\" does not implement IViewEngine interface!");
}
|
1b8a151b |
$vn = new ViewEngineInfo($fileExtension, $viewEngine, $config);
$this->viewengines[$fileExtension] = $vn;
|
cdfe8eaf |
}
public function get($fileExtension){
if(array_key_exists($fileExtension, $this->viewengines)){
return $this->viewengines[$fileExtension];
}
else{
return null;
}
}
public function getRegisteredFileExtensions(){
return array_keys($this->viewengines);
}
}
|