public function setUp() { $this->front = Zend_Controller_Front::getInstance(); $this->front->resetInstance(); $this->front->setParam('noViewRenderer', true)->setParam('noErrorHandler', true)->throwExceptions(true); Zend_Controller_Action_HelperBroker::resetHelpers(); //$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); //$viewRenderer->setActionController(); }
public function testPostDispatchDoesNotRenderViewWhenNoViewRendererSet() { $this->request->setModuleName('bar')->setControllerName('index')->setActionName('index'); $this->front->setParam('noViewRenderer', true); $controller = new Bar_IndexController($this->request, $this->response, array()); $this->helper->postDispatch(); $body = $this->response->getBody(); $this->assertTrue(empty($body)); }
/** * Add modules */ public function initModules() { $this->frontController->addModuleDirectory($this->corePath . '/application/modules'); foreach ($this->modules as $module) { $this->frontController->addControllerDirectory($this->corePath . '/application/modules/' . $module . '/controllers', $module); } $this->frontController->setParam('useDefaultControllerAlways', true); $this->frontController->setBaseUrl($this->config->general->baseUrl); $this->registry->set('baseUrl', $this->config->general->baseUrl); }
/** * init application * @return void */ protected function _initApplication() { Zend_Session::setOptions(array('name' => $this->settings->page->session->name, 'save_path' => realpath(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'sessions'))); Zend_Session::start(); // sollte wenn name feststeht ge�ndert werden # get an instance of the frontend controller $this->bootstrap('FrontController'); $this->frontController = Zend_Controller_Front::getInstance(); # now add our own dispatcher $this->frontController->setDispatcher(new FansubCMS_Controller_Dispatcher_Standard()); # prefix default module as well $this->frontController->setParam('prefixDefaultModule', true); # set default and module controller directrories // $this->frontController->setControllerDirectory($this->settings->controllers->toArray()); $this->frontController->addModuleDirectory(APPLICATION_PATH . "/modules"); $this->frontController->removeControllerDirectory('default'); # set default module $this->frontController->setDefaultModule("news"); # Init application-wide Session $applicationSessionNamespace = new Zend_Session_Namespace('application'); $applicationSessionNamespace->tstamp = !isset($applicationSessionNamespace->tstamp) ? time() : $applicationSessionNamespace->tstamp; # add it to the registry Zend_Registry::set('applicationSessionNamespace', $applicationSessionNamespace); # Init authentication Session $authSessionNamespace = new Zend_Session_Namespace('Zend_Auth'); # add it to the registry Zend_Registry::set('AuthSessionNamespace', $authSessionNamespace); # set timezone date_default_timezone_set(empty($this->settings->page->timezone) ? 'Europe/Berlin' : $this->settings->page->timezone); # hook to settings $this->settings->applicationStatus = $this->applicationStatus; # hook needed objects/values to the zend registry Zend_Registry::set('settings', $this->settings); Zend_Registry::set('applicationStatus', $this->applicationStatus); Zend_Registry::set('environmentSettings', $this->environmentsettings); Zend_Registry::set('emailSettings', $this->mailsettings); }
/** * Initialises the application * */ public function init() { $__start = getmicrotime(); if (isset($this->config['log_file'])) { $writer = new Zend_Log_Writer_Stream($this->config['log_file']); $this->logger = new Zend_Log($writer); if (isset($this->config['log_format'])) { $formatter = new Zend_Log_Formatter_Simple($this->config['log_format']); $writer->setFormatter($formatter); } // If not in debug mode, hide debug log messages if (!ifset($this->config, 'debug', false)) { $this->logger->addFilter(Zend_Log::NOTICE); } } $this->recordStat('za::initlog', getmicrotime() - $__start); $__start = getmicrotime(); $mailServer = $this->getConfig('smtp_server'); if (mb_strlen($mailServer)) { ini_set('SMTP', $mailServer); } // Create a new view object. $view = new CompositeView(); Zend_Registry::set(self::$ZEND_VIEW, $view); /* @var Zend_Controller_Front $controller */ $this->frontController = Zend_Controller_Front::getInstance(); $this->frontController->setDispatcher(new InjectingDispatcher()); $this->frontController->addControllerDirectory($this->getConfig('controller_dir', 'controllers'), 'default'); $modules = ifset($this->config, 'modules', array()); foreach ($modules as $module) { if (is_dir(APP_DIR . '/modules/' . $module)) { $this->frontController->addControllerDirectory('modules/' . $module, $module); } } $this->recordStat('za::initmodules', getmicrotime() - $__start); $__start = getmicrotime(); $this->frontController->throwExceptions(ifset($this->config, 'debug', false) ? true : false); if (isset($this->config['route_config']) && php_sapi_name() != 'cli') { $router = $this->frontController->getRouter(); /* @var $router Zend_Controller_Router_Rewrite */ $config = new Zend_Config_Ini($this->config['route_config'], 'routes'); $router->addConfig($config, 'routes'); } Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); $this->frontController->setParam('noViewRenderer', true); /** * Set the session */ $session_name = str_replace(' ', '_', $this->config['name']); Zend_Session::start(array('name' => $session_name)); $this->injector->addAutoProperty('log', $this->logger); $__start = getmicrotime(); // $services = $this->loadDefaultServices(); $this->injector->addServiceDirectory(NOVEMBER_APP_DIR . '/services'); // $this->injector->loadServices($this->config['services']); $this->recordStat('za::initdefaultservices', getmicrotime() - $__start); $__start = getmicrotime(); // // foreach ($services as $defaultService) { // $this->injector->inject($defaultService); // } // $this->recordStat('za::initinjectdefaultservices', getmicrotime() - $__start); $__start = getmicrotime(); // Load extensions $this->loadExtensions(); $this->injector->addServiceDirectory(ifset($this->config, 'services_dir', APP_DIR . '/services')); $this->recordStat('za::initloadext', getmicrotime() - $__start); $__start = getmicrotime(); $this->injector->loadServices($this->config['services']); $this->recordStat('za::initloadservices', getmicrotime() - $__start); $__start = getmicrotime(); // We know that there's definitely going to be an AuthService, // so we can now go and load the user if there was one in // the session. $auth = $this->injector->getService('AuthService'); if (isset($this->getSession()->CURRENT_USER_TICKET) && mb_strlen($this->getSession()->CURRENT_USER_TICKET)) { $auth->validateTicket($this->getSession()->CURRENT_USER_NAME, $this->getSession()->CURRENT_USER_TICKET); } $this->recordStat('za::initvalidateauth', getmicrotime() - $__start); }
/** * @static * @param \Zend_Controller_Front $front */ public static function initControllerFront(\Zend_Controller_Front $front) { // disable build-in error handler $front->setParam('noErrorHandler', true); // for admin an other modules directly in the core $front->addModuleDirectory(PIMCORE_PATH . "/modules"); // for plugins if (is_dir(PIMCORE_PLUGINS_PATH) && is_readable(PIMCORE_PLUGINS_PATH)) { $front->addModuleDirectory(PIMCORE_PLUGINS_PATH); } // for frontend (default: website) $front->addControllerDirectory(PIMCORE_WEBSITE_PATH . "/controllers", PIMCORE_FRONTEND_MODULE); $front->setDefaultModule(PIMCORE_FRONTEND_MODULE); }
/** * Route to APImodule * @param \Zend_Controller_Front $front */ private function routeToApi(\Zend_Controller_Front $front) { $errorPlugin = new \Zend_Controller_Plugin_ErrorHandler(); $errorPlugin->setErrorHandlerController(BaseRouter::DEFAULT_ERROR_CONTROLLER); $errorPlugin->setErrorHandlerAction(BaseRouter::DEFAULT_ERROR_ACTION); $errorPlugin->setErrorHandlerModule(ApiRouter::API_MODULE); $front->setParam('noViewRenderer', true); $front->setRequest(new ApiRequest())->setRouter(new ApiRouter())->registerPlugin($errorPlugin); }