Errors and exceptions handling, #16

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@121 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
pzinovkin
2010-03-07 17:26:44 +00:00
parent 2d7f5391f8
commit 4f7e5b00bc
7 changed files with 305 additions and 82 deletions

View File

@ -17,9 +17,12 @@ class PHPView implements iView
protected $extension = '.phtml';
protected $template = '';
public function __construct($path)
public function __construct($config)
{
$this->setPath($path);
if (!isset($config['path'])) {
throw new Exception('Configuration must have a "host".');
}
$this->setPath($config['path']);
}
public function getPath()
@ -53,10 +56,11 @@ class PHPView implements iView
unset($template);
extract($this->variables);
ob_start();
if (!(include($this->template)) == 'OK') {
if (!is_readable($this->template)) {
ob_clean();
throw new Exception('Template "' . $this->template .'" not found.');
}
include($this->template);
return ob_get_clean();
}