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.

41 lines
955 B

<?php
/**
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage app
* @since 2010-02-25
* @version SVN: $Id$
* @filesource $URL$
*/
abstract class ViewAction extends Action
{
protected $template;
/**
* @var PHPView
*/
protected $view;
public function __construct()
{
$this->view = FrontController::getInstance()->getView();
parent::__construct();
}
protected function getTemplate()
{
$class = get_class($this);
$template = ($this->template) ? $this->template : substr($class, 0, -6/*strlen('Action')*/);
$dir = array_slice(explode('/', Load::getFilePath($class)), -2, 1);
return '/actions/' . array_pop($dir) . '/' . $template;
}
public function fetch()
{
$this->view->assignObject($this);
return $this->view->fetch($this->getTemplate());
}
}