Memcache, refactoring, View helpers, #16

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@124 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
pzinovkin
2010-03-13 23:33:46 +00:00
parent 4a22759e3d
commit 8fc917dca2
19 changed files with 706 additions and 147 deletions

View File

@ -9,11 +9,15 @@
* @filesource $URL$
*/
/**
* @method ViewHelperGet get()
*/
class PHPView implements iView
{
protected $path = '';
protected $variables = array();
protected $helpers = array();
protected $extension = '.phtml';
protected $template = '';
@ -69,6 +73,31 @@ class PHPView implements iView
return htmlentities($var, ENT_QUOTES, 'UTF-8');
}
/**
* Helpers call
*
* @param mixed $name
* @param mixed $args
* @return ViewHelper
*/
public function __call($name, $args)
{
$helper = $this->getHelper($name);
return call_user_func_array(array($helper, $name), $args);
}
protected function getHelper($name)
{
if (!isset($this->helpers[$name])) {
$class = 'ViewHelper' . ucfirst($name);
if (!class_exists($class)) {
throw new GeneralException('View helper "' . $class . '" not found.');
}
$this->helpers[$name] = new $class($this);
}
return $this->helpers[$name];
}
protected function getTemplatePath($template)
{
return $this->path . $template . $this->extension;