144 lines
3.7 KiB
PHP
144 lines
3.7 KiB
PHP
<?php
|
|
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|
{
|
|
/**
|
|
* Set config available in all apps
|
|
*/
|
|
protected function _initConfig()
|
|
{
|
|
$config = new Zend_Config($this->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(
|
|
'auth' => __DIR__ . '/modules/auth/controllers',
|
|
'default' => __DIR__ . '/modules/default/controllers',
|
|
'file' => __DIR__ . '/modules/file/controllers',
|
|
'help' => __DIR__ . '/modules/help/controllers',
|
|
'print' => __DIR__ . '/modules/print/controllers',
|
|
'search' => __DIR__ . '/modules/search/controllers',
|
|
'user' => __DIR__ . '/modules/user/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();
|
|
|
|
$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' => 'auth',
|
|
'controller' => 'sso',
|
|
'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);
|
|
}
|
|
|
|
/**
|
|
* 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 '<pre>'; print_r($e); echo '</pre>';
|
|
} 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()
|
|
{
|
|
//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);
|
|
}
|
|
|
|
} |