156 lines
4.6 KiB
PHP
156 lines
4.6 KiB
PHP
<?php
|
|
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|
{
|
|
protected function _initConfig()
|
|
{
|
|
$config = new Zend_Config($this->getOptions());
|
|
Zend_Registry::set('config', $config);
|
|
|
|
//Load old config
|
|
require_once 'WsScore/Configure.php';
|
|
$oldconfig = new Configure();
|
|
|
|
return $config;
|
|
}
|
|
|
|
//Initialisation global des paramètres de vue
|
|
protected function _initViewSettings()
|
|
{
|
|
$this->bootstrap('view');
|
|
|
|
$view = $this->getResource('view');
|
|
$view->setEncoding('UTF-8');
|
|
$view->doctype('HTML5');
|
|
|
|
$view->headMeta()
|
|
->appendHttpEquiv('viewport', 'width=device-width, initial-scale=1.0')
|
|
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
|
|
->appendHttpEquiv('Content-Language', 'fr-FR');
|
|
|
|
$view->headLink()
|
|
->appendStylesheet('/libs/bootstrap-v3.0.2/css/bootstrap.min.css', 'all')
|
|
->appendStylesheet('/themes/default/css/docs.css', 'all')
|
|
->appendStylesheet('/themes/default/css/main.css', 'all');
|
|
|
|
$view->headScript()
|
|
->appendFile('/libs/html5shiv.js', 'text/javascript', array('conditional' => 'lt IE 9'))
|
|
->appendFile('/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9'));
|
|
|
|
$view->inlineScript()
|
|
->appendFile('/libs/jquery-2.0.3.min.js', 'text/javascript')
|
|
->appendFile('/libs/bootstrap-v3.0.2/js/bootstrap.min.js', 'text/javascript');
|
|
|
|
$view->headTitle()->setSeparator(' - ');
|
|
$view->headTitle('Web Service API - Scores & Decisions');
|
|
}
|
|
|
|
//Initialisation global des paramètres de log
|
|
protected function _initLogging()
|
|
{
|
|
/*$c = Zend_Registry::get('config');
|
|
$WsLogger = new Zend_Log();
|
|
$WsFileWriter = new Zend_Log_Writer_Stream($c->profil->path->log.'/wsentreprise.log');
|
|
$WsFileWriter->addFilter(Zend_Log::INFO);
|
|
$WsLogger->addWriter($WsFileWriter);
|
|
Zend_Registry::set('WsLogger', $WsLogger);*/
|
|
}
|
|
|
|
protected function _initRouter()
|
|
{
|
|
$this->bootstrap('frontController');
|
|
$front = $this->getResource('frontController');
|
|
$router = $front->getRouter();
|
|
|
|
//Lire les services disponibles et créer les routes
|
|
$services = require_once APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
|
|
foreach( $services as $section => $params )
|
|
{
|
|
if ($params['actif']) {
|
|
$route = new Zend_Controller_Router_Route($section.'/:version', array(
|
|
'controller' => 'service',
|
|
'action' => 'index',
|
|
'service' => $section,
|
|
'version' => '',
|
|
));
|
|
$router->addRoute($section, $route);
|
|
|
|
$route = new Zend_Controller_Router_Route('jsonrpc/'.$section.'/:version', array(
|
|
'controller' => 'jsonrpc',
|
|
'action' => 'index',
|
|
'service' => $section,
|
|
'version' => '',
|
|
));
|
|
$router->addRoute('jsonrpc-'.$section, $route);
|
|
}
|
|
}
|
|
|
|
//Route pour WS Clients
|
|
$route = new Zend_Controller_Router_Route('clients/:client/:version', array(
|
|
'controller' => 'service',
|
|
'action' => 'index',
|
|
'service' => 'clients',
|
|
'client' => '',
|
|
'version' => ''
|
|
));
|
|
$router->addRoute('client', $route);
|
|
|
|
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
|
|
'controller' => 'fichier',
|
|
'fichier' => '',
|
|
));
|
|
$router->addRoute('fichier', $fichierRoute);
|
|
return $router;
|
|
}
|
|
|
|
protected function _initDb()
|
|
{
|
|
$c = Zend_Registry::get('config');
|
|
try {
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
} 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);
|
|
}
|
|
|
|
protected function _initWsDebug()
|
|
{
|
|
$autoloader = Zend_Loader_Autoloader::getInstance();
|
|
$autoloader->registerNamespace('WsDebug');
|
|
|
|
$options = array(
|
|
'plugins' => array(
|
|
'Exception',
|
|
),
|
|
);
|
|
|
|
$debug = new WsDebug_Controller_Plugin_Debug($options);
|
|
|
|
$this->bootstrap('frontController');
|
|
$frontController = $this->getResource('frontController');
|
|
$frontController->registerPlugin($debug);
|
|
}
|
|
|
|
protected function _initCache()
|
|
{
|
|
if ( APPLICATION_ENV!='development' ) {
|
|
//MetadataCache pour la base de données
|
|
$frontendOptions = array(
|
|
'lifetime' => 14400,
|
|
'automatic_serialization' => true
|
|
);
|
|
$backendOptions = array();
|
|
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions);
|
|
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
|
|
}
|
|
}
|
|
} |