/** * Creates the view context */ public function __construct() { $path = array_reverse(explode('\\', get_class($this))); $moduleName = ''; $controllerName = 'index'; switch (count($path)) { case 3: $moduleName = Filter::camelCaseToDash($path[2]); case 2: $controllerName = Filter::camelCaseToDash($path[1]); case 1: $viewName = Filter::camelCaseToDash(substr($path[0], 8)); } $basePath = APPLICATION_PATH; if ($moduleName) { $basePath .= '/modules/' . $moduleName; } $this->_controllerName = $controllerName; $basePath .= '/views/'; if (!file_exists($basePath) || !is_dir($basePath)) { require_once 'Zend/Controller/Exception.php'; throw new \Zend_Controller_Exception('Missing base view directory ("' . $basePath . '")'); } require_once 'Zend/View.php'; $this->_view = new \Zend_View(array('basePath' => $basePath)); $this->_viewScript = $this->_controllerName . "/{$viewName}.phtml"; }