CS
This commit is contained in:
parent
8a9b75bec5
commit
278b80f1b8
@ -22,37 +22,31 @@ class ServiceController extends Zend_Controller_Action
|
||||
$serviceClassName = ucfirst($serviceName);
|
||||
|
||||
// --- Customize service for customers
|
||||
if ( 'clients' == $serviceName )
|
||||
{
|
||||
if ('clients' == $serviceName) {
|
||||
$client = strtolower($request->getParam('client', ''));
|
||||
$clientClassName = ucfirst($client);
|
||||
// --- Get list of customers
|
||||
$clients = array();
|
||||
$listeClients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
|
||||
foreach ( $listeClients as $section => $params )
|
||||
{
|
||||
if ($params['actif'])
|
||||
{
|
||||
foreach ( $listeClients as $section => $params ) {
|
||||
if ($params['actif']) {
|
||||
$clients[$section] = $params;
|
||||
}
|
||||
}
|
||||
if (!array_key_exists($client, $clients))
|
||||
{
|
||||
if (!array_key_exists($client, $clients)) {
|
||||
echo 'Service clients introuvable !';
|
||||
exit;
|
||||
}
|
||||
$configServiceVersions = $clients[$client]['versions'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// --- Service versions
|
||||
// --- Service versions
|
||||
else {
|
||||
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
|
||||
$configServiceVersions = $services[$serviceName]['versions'];
|
||||
}
|
||||
|
||||
// --- Check versions
|
||||
foreach( $configServiceVersions as $section => $params )
|
||||
{
|
||||
foreach ($configServiceVersions as $section => $params) {
|
||||
$serviceVersions[$section] = $params;
|
||||
if ($params['defaut']) {
|
||||
$defautVersion = $section;
|
||||
@ -62,21 +56,18 @@ class ServiceController extends Zend_Controller_Action
|
||||
$version = substr($version, 1);
|
||||
|
||||
// --- Version inexistante
|
||||
if ( !array_key_exists($version, $serviceVersions) )
|
||||
{
|
||||
if (!array_key_exists($version, $serviceVersions)) {
|
||||
echo "Version inexistante.";
|
||||
exit;
|
||||
}
|
||||
// --- Version désactivé
|
||||
if ( !$serviceVersions[$version]['actif'] )
|
||||
{
|
||||
if (!$serviceVersions[$version]['actif']) {
|
||||
echo "Version désactivée.";
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- Charger les classes et les types pour le service suivant la version
|
||||
if ('clients' == $serviceName)
|
||||
{
|
||||
if ('clients' == $serviceName) {
|
||||
$pathServiceClassIni = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Config.php';
|
||||
$pathServiceClassPhp = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Service.php';
|
||||
// --- Gestion du mode de génération du wsdl
|
||||
@ -84,15 +75,15 @@ class ServiceController extends Zend_Controller_Action
|
||||
|| array_key_exists('mode', $serviceVersions[$version])
|
||||
&& $serviceVersions[$version]['mode']=='auto') {
|
||||
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl';
|
||||
}
|
||||
// --- On redéfini le nom du service
|
||||
$serviceClassName = 'Entreprise';
|
||||
$fichierWsdl = $clientClassName.'-'.$serviceClassName.'-'.$version.'.wsdl';
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$pathServiceClassIni = 'WsScore/'.$serviceClassName.'/v'.$version.'/Config.php';
|
||||
$pathServiceClassPhp = 'WsScore/'.$serviceClassName.'/v'.$version.'/Service.php';
|
||||
// --- Gestion du mode de génération du wsdl
|
||||
@ -100,7 +91,8 @@ class ServiceController extends Zend_Controller_Action
|
||||
|| array_key_exists('mode', $serviceVersions[$version])
|
||||
&& $serviceVersions[$version]['mode']=='auto') {
|
||||
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl';
|
||||
}
|
||||
$fichierWsdl = $serviceClassName.'-'.$version.'.wsdl';
|
||||
@ -120,17 +112,15 @@ class ServiceController extends Zend_Controller_Action
|
||||
$wsdlPath = $c->profil->path->shared . '/wsdl';
|
||||
|
||||
// --- Fourniture du wsdl
|
||||
if ( isset($_GET['wsdl']) && file_exists($wsdlPath . '/' . $fichierWsdl) )
|
||||
{
|
||||
if (isset($_GET['wsdl']) && file_exists($wsdlPath . '/' . $fichierWsdl)) {
|
||||
if (!headers_sent()) {
|
||||
header('Content-Type: text/xml');
|
||||
}
|
||||
readfile($wsdlPath . '/' . $fichierWsdl);
|
||||
}
|
||||
elseif ( isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)
|
||||
|| isset($_GET['wsdl-generate'])
|
||||
|| isset($_GET['wsdl-auto']) )
|
||||
{
|
||||
|| isset($_GET['wsdl-generate'])
|
||||
|| isset($_GET['wsdl-auto']) ) {
|
||||
// --- Définition du webservice
|
||||
$wsdl = new Zend_Soap_AutoDiscover();
|
||||
$wsdl->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
|
||||
@ -153,27 +143,27 @@ class ServiceController extends Zend_Controller_Action
|
||||
header('Content-Type: text/xml');
|
||||
}
|
||||
readfile($wsdlPath . '/' . $fichierWsdl);
|
||||
|
||||
}
|
||||
// --- Envoi sur la sortie standard le wsdl sans enregistrement dans un fichier
|
||||
} elseif ( isset($_GET['wsdl-auto']) ){
|
||||
elseif ( isset($_GET['wsdl-auto']) ){
|
||||
$wsdl->handle();
|
||||
}
|
||||
}
|
||||
// --- Fourniture du service
|
||||
else
|
||||
{
|
||||
else {
|
||||
// --- Traitement
|
||||
if (in_array(APPLICATION_ENV, array('production', 'staging')) && file_exists($wsdlPath . '/' . $fichierWsdl)) {
|
||||
if (in_array(APPLICATION_ENV, array('production', 'staging'))
|
||||
&& file_exists($wsdlPath . '/' . $fichierWsdl)) {
|
||||
$server = new Zend_Soap_Server($wsdlPath . '/' . $fichierWsdl);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$server = new Zend_Soap_Server('http://'.$hostName.'/'.$pathServiceUrl);
|
||||
}
|
||||
|
||||
// --- Sonde paramètres server
|
||||
$debug = false;
|
||||
$debugUser = '';
|
||||
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser)
|
||||
{
|
||||
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser) {
|
||||
file_put_contents(APPLICATION_PATH . '/../debugserver.log',
|
||||
"FichierWSDL : ".$fichierWsdl."\n".
|
||||
"Hostname : ".$hostName."\n"
|
||||
@ -186,6 +176,8 @@ class ServiceController extends Zend_Controller_Action
|
||||
$server->setEncoding('UTF-8');
|
||||
$server->registerFaultException(array('Scores_Ws_Exception'));
|
||||
$server->setWsiCompliant(true);
|
||||
|
||||
// --- Création du service
|
||||
$server->setObject(new $serviceClassName());
|
||||
$server->handle();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user