extranet/application/Bootstrap.php

122 lines
3.3 KiB
PHP
Raw Normal View History

2010-11-22 13:50:12 +01:00
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
2012-07-30 11:13:34 +02:00
{
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
//Initialisation global des paramètres de vue
2010-11-22 13:50:12 +01:00
protected function _initViewSettings()
{
2011-01-11 09:43:13 +01:00
$this->bootstrap('view');
2012-07-30 11:13:34 +02:00
$view = $this->getResource('view');
$view->setEncoding('UTF-8');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Extranet Scores & Décisions');
2010-11-22 13:50:12 +01:00
}
2011-01-05 10:59:49 +01:00
protected function _initRouter()
{
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$router = $front->getRouter();
2011-04-28 12:24:53 +02:00
$localauthRoute = new Zend_Controller_Router_Route('localauth/', array(
'controller' => 'user',
'action' => 'login'
2011-01-05 10:59:49 +01:00
));
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
2011-04-28 12:24:53 +02:00
'controller' => 'fichier',
'fichier' => '',
));
$printRoute = new Zend_Controller_Router_Route('editer/:action/:fichier', array(
'controller' => 'print',
'fichier' => '',
));
2011-04-28 12:24:53 +02:00
$router->addRoute('localauth', $localauthRoute);
$router->addRoute('fichier', $fichierRoute);
$router->addRoute('print', $printRoute);
2011-01-05 10:59:49 +01:00
return $router;
}
protected function _initLogging()
{
2012-07-30 11:13:34 +02:00
//Firebug
2011-01-07 18:16:07 +01:00
$writer = new Zend_Log_Writer_Firebug();
2011-09-27 11:13:13 +02:00
if(APPLICATION_ENV=='production') {
2012-07-30 11:13:34 +02:00
$writer->setEnabled(false);
2011-09-27 11:13:13 +02:00
}
2011-01-07 18:16:07 +01:00
$logger = new Zend_Log($writer);
Zend_Registry::set('firebug', $logger);
2011-09-27 11:13:13 +02:00
//ChromePHP - a voir comment désactiver
2012-07-30 11:13:34 +02:00
require_once 'Vendors/ChromePHP/ChromePhp.php';
//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);
}
/* Remove as it's not use
$c = Zend_Registry::get('config');
$path = $c->profil->path->data.'/log';
$AppFileWriter = new Zend_Log_Writer_Stream($path.'/application.log');
$AppFileWriter->addFilter(Zend_Log::ERR);
$AppLogger->addWriter($AppFileWriter);
*/
Zend_Registry::set('log', $AppLogger);
}
protected function _initDb()
{
2014-02-26 00:27:46 +01:00
$c = Zend_Registry::get('config');
try {
2014-02-26 00:27:46 +01:00
$db = Zend_Db::factory($c->profil->db->sdv1);
2012-07-30 11:13:34 +02:00
$db->getConnection();
} catch ( Exception $e ) {
2012-07-30 11:13:34 +02:00
if (APPLICATION_ENV == 'development') {
echo '<pre>'; print_r($e); echo '</pre>';
2012-07-30 11:13:34 +02:00
} else {
echo "Le service rencontre actuellement un problème technique.";
}
exit;
}
2012-07-30 11:13:34 +02:00
/**
* Set the default adapter to use with all model
*/
Zend_Db_Table::setDefaultAdapter($db);
2012-07-30 11:13:34 +02:00
/**
* Set Firebug Database profiler
*/
if (APPLICATION_ENV == 'development') {
$profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
$profiler->setEnabled(true);
$db->setProfiler($profiler);
}
}
2012-03-15 16:56:06 +01:00
protected function _initCache()
{
//MetadataCache pour la base de données
2013-06-03 09:17:05 +02:00
$cache = Zend_Cache::factory(
'Core',
'Apc',
array('lifetime' => 28800,'automatic_serialization' => true),
array()
);
2013-05-29 15:10:19 +02:00
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
2012-03-15 16:56:06 +01:00
}
2013-05-29 15:10:19 +02:00
}