getOptions()); Zend_Registry::set('config', $config); return $config; } /** * Init controller with modules */ protected function _initController() { $this->bootstrap('frontController'); $front = $this->getResource('frontController'); $front->setControllerDirectory(array( 'default' => __DIR__ . '/modules/default/controllers', 'admin' => __DIR__ . '/modules/admin/controllers', 'file' => __DIR__ . '/modules/file/controllers', )); return $front; } /** * Initialisation global des paramètres de vue */ protected function _initViewSettings() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->setEncoding('UTF-8'); $view->headTitle()->setSeparator(' - '); $view->headTitle('Extranet Scores & Décisions'); } /** * Some specific route * @return unknown */ protected function _initRouter() { $this->bootstrap('frontController'); $front = $this->getResource('frontController'); $router = $front->getRouter(); $localauthRoute = new Zend_Controller_Router_Route('localauth/', array( 'module' => 'default', 'controller' => 'user', 'action' => 'login' )); $router->addRoute('localauth', $localauthRoute); $printRoute = new Zend_Controller_Router_Route('editer/:action/:fichier', array( 'module' => 'default', 'controller' => 'print', 'fichier' => '', )); $router->addRoute('print', $printRoute); $ssoRoute = new Zend_Controller_Router_Route('sso/:partner/', array( 'module' => 'default', 'controller' => 'auth', 'action' => 'index', )); $router->addRoute('sso', $ssoRoute); return $router; } protected function _initLogging() { //Firebug $writer = new Zend_Log_Writer_Firebug(); if(APPLICATION_ENV=='production') { $writer->setEnabled(false); } $logger = new Zend_Log($writer); Zend_Registry::set('firebug', $logger); //Application Logger en Production $AppLogger = new Zend_Log(); if (APPLICATION_ENV == 'production') { $Mail = new Zend_Mail(); $Mail->setFrom('production@scores-decisions.com') ->addTo('supportdev@scores-decisions.com'); $AppMailWriter = new Zend_Log_Writer_Mail($Mail); $AppMailWriter->setSubjectPrependText('ERREUR'); $AppMailWriter->addFilter(Zend_Log::ERR); $AppLogger->addWriter($AppMailWriter); } Zend_Registry::set('log', $AppLogger); } /** * Logs and Debug */ protected function _initLogger() { $config = new Zend_Config($this->getOptions()); $logFile = $config->profil->path->shared.'/log/application.log'; $log = new Logger('APP'); // Console Handler if (in_array(APPLICATION_ENV, array('development', 'staging'))) { //$log->pushHandler(new BrowserConsoleHandler()); //$log->pushHandler(new ChromePHPHandler()); } // File Handler if (APPLICATION_ENV == 'development') { $level = Logger::DEBUG; } else { $level = Logger::INFO; } $log->pushHandler(new StreamHandler($logFile), $level); // Processor $log->pushProcessor(new IntrospectionProcessor()); Zend_Registry::set('logger', $log); } /** * Init database */ protected function _initDb() { $c = Zend_Registry::get('config'); try { $db = Zend_Db::factory($c->profil->db->sdv1); $db->getConnection(); } catch ( Exception $e ) { if (APPLICATION_ENV == 'development') { echo '
'; print_r($e); echo '
'; } else { echo "Le service rencontre actuellement un problème technique."; } exit; } /** * Set the default adapter to use with all model */ Zend_Db_Table::setDefaultAdapter($db); /** * Set Firebug Database profiler */ if (APPLICATION_ENV == 'development') { $profiler = new Zend_Db_Profiler_Firebug('All DB Queries'); $profiler->setEnabled(true); $db->setProfiler($profiler); } } /** * Init cache */ protected function _initCache() { // @todo : Remove for PHP7 Compatibility //MetadataCache pour la base de données $cache = Zend_Cache::factory('Core', 'Apc', array('lifetime' => 28800, 'automatic_serialization' => true), array() ); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); } }