/** * Pre-dispatch hook to create and install a replacement View object. * * @param Zend_Controller_Request_Abstract $request The requst object. * * @return void */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { // Unregister the built-in autoloader spl_autoload_unregister(array('PHPTAL', 'autoload')); // Register the autoloader through Zend Zend_Loader_Autoloader::getInstance()->pushAutoloader(array('PHPTAL', 'autoload'), 'PHPTAL'); // We create an instance of our view wrapper and configure it // It extends Zend_View so we can configure it the same way $view = new Ztal_Tal_View($this->_options); if (Zend_Registry::isRegistered('Zend_Translate')) { //setup the translation facilities in PHPTal $translator = new Ztal_Tal_ZendTranslateTranslator($this->_options); $translator->useDomain($request->getControllerName()); $view->getEngine()->setTranslator($translator); } // Call out to an overloadable method to pickup the paths for // templates for the current module foreach ($this->_currentModuleTemplatePaths($request) as $currentPath) { $view->addTemplateRepositoryPath($currentPath); } // We configure the view renderer in order to use our PHPTAL view $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setViewSuffix('phtml'); $view->layout()->setViewSuffix('phtml'); $viewRenderer->setView($view); Zend_Registry::set('Ztal_View', $view); }