getOptions()); Zend_Registry::set('config', $config); define('MYSQL_HOST', $config->profil->db->metier->params->host); define('MYSQL_USER', $config->profil->db->metier->params->username); define('MYSQL_PASS', $config->profil->db->metier->params->password); define('LOG_PATH', $config->profil->path->shared.'/log'); // Entreprise define('SPHINX_ENT_HOST', $config->profil->sphinx->ent->host); define('SPHINX_ENT_PORT', intval($config->profil->sphinx->ent->port)); define('SPHINX_ENT_VERSION', $config->profil->sphinx->ent->version); // Dirigeants define('SPHINX_DIR_HOST', $config->profil->sphinx->dir->host); define('SPHINX_DIR_PORT', intval($config->profil->sphinx->dir->port)); define('SPHINX_DIR_VERSION', $config->profil->sphinx->dir->version); // Historique define('SPHINX_HISTO_HOST', $config->profil->sphinx->histo->host); define('SPHINX_HISTO_PORT', intval($config->profil->sphinx->histo->port)); define('SPHINX_HISTO_VERSION', $config->profil->sphinx->histo->version); // Actionnaire define('SPHINX_ACT_HOST', $config->profil->sphinx->act->host); define('SPHINX_ACT_PORT', intval($config->profil->sphinx->act->port)); define('SPHINX_ACT_VERSION', $config->profil->sphinx->act->version); //Old define('SPHINX_HOST', $config->profil->sphinx->ent->host); define('SPHINX_PORT', intval($config->profil->sphinx->ent->port)); 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() ->appendName('viewport', 'width=device-width, initial-scale=1.0') ->appendHttpEquiv('X-UA-Compatible', 'IE=edge') ->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8') ->appendHttpEquiv('Content-Language', 'fr-FR'); //Favicon - Touch icon for iOS 2.0+ and Android 2.1+ $view->headLink()->headLink(array( 'rel' => 'apple-touch-icon-precomposed', 'href' => '/favicon-152.png' )); //Favicon - targeted to any additional png size $view->headLink()->headLink(array( 'rel' => 'icon', 'type' => 'image/png', 'href' => '/favicon-32.png' )); $view->headLink()->headLink(array( 'rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/favicon.ico') ); $view->headLink() ->appendStylesheet('/assets/libs/bootstrap-3.3.7/css/bootstrap.min.css', 'all') ->appendStylesheet('/assets/themes/default/css/docs.css', 'all') ->appendStylesheet('/assets/themes/default/css/main.css', 'all'); $view->headScript() ->appendFile('/assets/libs/html5shiv.min.js', 'text/javascript', array('conditional' => 'lt IE 9')) ->appendFile('/assets/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9')) ->appendFile('/assets/libs/jquery-1.12.4.min.js', 'text/javascript') ->appendFile('/assets/libs/bootstrap-3.3.7/js/bootstrap.min.js', 'text/javascript'); $view->headTitle()->setSeparator(' - '); $view->headTitle('Web Service API - Scores & Decisions'); } 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 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 = new Zend_Config($this->getOptions()); try { $db = Zend_Db::factory($c->profil->db->metier); } 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); } protected function _initDoctrine() { $c = new Zend_Config($this->getOptions()); $config = new \Doctrine\DBAL\Configuration(); if (APPLICATION_ENV == 'development') { $logger = new Scores_Logger_Sql(); $config->setSQLLogger($logger); } $connectionParams = array( 'dbname' => $c->profil->db->metier->params->dbname, 'user' => $c->profil->db->metier->params->username, 'password' => $c->profil->db->metier->params->password, 'host' => $c->profil->db->metier->params->host, 'charset' => 'utf8', 'driver' => 'pdo_mysql', ); try { $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config); } catch (\Doctrine\DBAL\DBALException $e) { if (APPLICATION_ENV == 'development') { echo '
';
                print_r($e);
                echo '
'; } else { echo "Le service rencontre actuellement un problème technique."; } exit; } Zend_Registry::set('doctrine', $conn); } 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); } } protected function _initLogger() { $config = new Zend_Config($this->getOptions()); $logFile = $config->profil->path->shared.'/log/application.log'; $log = new Logger('APP'); if (APPLICATION_ENV == 'development') { $level = Logger::DEBUG; } else { $level = Logger::NOTICE; } $log->pushHandler(new StreamHandler($logFile, $level)); $log->pushProcessor(new IntrospectionProcessor()); Zend_Registry::set('logger', $log); } }