Loading src/UnicaenLeocarte/Controller/IndexController.php +5 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ class IndexController extends AbstractActionController implements PhotoServiceAw { $id = $this->params()->fromRoute('id'); $nocache = (bool) (int) $this->params()->fromQuery('nocache', '0'); $failure = false; try { $autorise = true; Loading @@ -48,6 +49,7 @@ class IndexController extends AbstractActionController implements PhotoServiceAw catch (ExtensionNotLoadedException $e) { // Extension 'gd' non installée $content = ''; $failure = true; } } } Loading @@ -61,11 +63,13 @@ class IndexController extends AbstractActionController implements PhotoServiceAw // Extension 'gd' non installée $content = ''; } $failure = true; } catch (RuntimeException $re) { // Erreur lors de l'appel du WS error_log("Erreur rencontrée lors de l'appel au web service Leocarte : " . $re->getMessage(), 0); $content = $this->photoService->createPhotoErreur(); $failure = true; } /** @var Response $response */ Loading @@ -78,7 +82,7 @@ class IndexController extends AbstractActionController implements PhotoServiceAw ->addHeaderLine('Content-Type', "image/jpeg") ->addHeaderLine('Content-length', strlen($content)); if ($nocache) { if ($nocache || $failure) { $headers ->addHeaderLine('Cache-Control', "no-cache") ->addHeaderLine('Pragma', 'no-cache'); Loading src/UnicaenLeocarte/Service/Photo/PhotoService.php +39 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class PhotoService implements SoapClientAwareInterface protected $generationPhotoNonAutoriseeConfig; /** * Retourne le témoin de droit d'utilisation de la photo. * Retourne le témoin de droit d'utilisation de la photo pour l'identifiant spécifié. * * @param string $identifiant Identifiant, ex: numéro étudiant * @return boolean Loading @@ -33,6 +33,9 @@ class PhotoService implements SoapClientAwareInterface { $result = $this->soapClient->getDroitUtilisationPhoto($identifiant); // suite à une mise à jour du SGC, le format du résultat se complique... $this->normalizeResult($result); if (! isset($result->return->persons)) { throw new NotFoundException("Requête infructueuse"); } Loading @@ -43,6 +46,7 @@ class PhotoService implements SoapClientAwareInterface } /** * Retourne la photo pour l'identifiant spécifié. * * @param string $identifiant Identifiant, ex: numéro étudiant * @return string Contenu "binaire" de la photo Loading @@ -52,6 +56,9 @@ class PhotoService implements SoapClientAwareInterface /** @var \stdClass $result */ $result = $this->soapClient->getPhoto($identifiant); // suite à une mise à jour du SGC, le format du résultat se complique... $this->normalizeResult($result); if (! isset($result->return->persons)) { throw new NotFoundException("Requête infructueuse"); } Loading @@ -62,6 +69,37 @@ class PhotoService implements SoapClientAwareInterface return $imgData; } /** * Normalise le format du résultat de la requête. * Autre chemin possible : "->return->resources". * * @param object $result */ protected function normalizeResult(&$result) { if (! isset($result->return->resources)) { return; } $data = $result->return->resources; if (is_array($data)) { $found = null; foreach ($data as $item) { if (isset($item->id) && $item->id > 0) { $found = $item; break; } } if ($found !== null) { $result->return->persons = $found; } } else { $result->return->persons = $data; } } /** * Fabrique une image informant d'une erreur lors de l'appel au WS. * Loading Loading
src/UnicaenLeocarte/Controller/IndexController.php +5 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ class IndexController extends AbstractActionController implements PhotoServiceAw { $id = $this->params()->fromRoute('id'); $nocache = (bool) (int) $this->params()->fromQuery('nocache', '0'); $failure = false; try { $autorise = true; Loading @@ -48,6 +49,7 @@ class IndexController extends AbstractActionController implements PhotoServiceAw catch (ExtensionNotLoadedException $e) { // Extension 'gd' non installée $content = ''; $failure = true; } } } Loading @@ -61,11 +63,13 @@ class IndexController extends AbstractActionController implements PhotoServiceAw // Extension 'gd' non installée $content = ''; } $failure = true; } catch (RuntimeException $re) { // Erreur lors de l'appel du WS error_log("Erreur rencontrée lors de l'appel au web service Leocarte : " . $re->getMessage(), 0); $content = $this->photoService->createPhotoErreur(); $failure = true; } /** @var Response $response */ Loading @@ -78,7 +82,7 @@ class IndexController extends AbstractActionController implements PhotoServiceAw ->addHeaderLine('Content-Type', "image/jpeg") ->addHeaderLine('Content-length', strlen($content)); if ($nocache) { if ($nocache || $failure) { $headers ->addHeaderLine('Cache-Control', "no-cache") ->addHeaderLine('Pragma', 'no-cache'); Loading
src/UnicaenLeocarte/Service/Photo/PhotoService.php +39 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class PhotoService implements SoapClientAwareInterface protected $generationPhotoNonAutoriseeConfig; /** * Retourne le témoin de droit d'utilisation de la photo. * Retourne le témoin de droit d'utilisation de la photo pour l'identifiant spécifié. * * @param string $identifiant Identifiant, ex: numéro étudiant * @return boolean Loading @@ -33,6 +33,9 @@ class PhotoService implements SoapClientAwareInterface { $result = $this->soapClient->getDroitUtilisationPhoto($identifiant); // suite à une mise à jour du SGC, le format du résultat se complique... $this->normalizeResult($result); if (! isset($result->return->persons)) { throw new NotFoundException("Requête infructueuse"); } Loading @@ -43,6 +46,7 @@ class PhotoService implements SoapClientAwareInterface } /** * Retourne la photo pour l'identifiant spécifié. * * @param string $identifiant Identifiant, ex: numéro étudiant * @return string Contenu "binaire" de la photo Loading @@ -52,6 +56,9 @@ class PhotoService implements SoapClientAwareInterface /** @var \stdClass $result */ $result = $this->soapClient->getPhoto($identifiant); // suite à une mise à jour du SGC, le format du résultat se complique... $this->normalizeResult($result); if (! isset($result->return->persons)) { throw new NotFoundException("Requête infructueuse"); } Loading @@ -62,6 +69,37 @@ class PhotoService implements SoapClientAwareInterface return $imgData; } /** * Normalise le format du résultat de la requête. * Autre chemin possible : "->return->resources". * * @param object $result */ protected function normalizeResult(&$result) { if (! isset($result->return->resources)) { return; } $data = $result->return->resources; if (is_array($data)) { $found = null; foreach ($data as $item) { if (isset($item->id) && $item->id > 0) { $found = $item; break; } } if ($found !== null) { $result->return->persons = $found; } } else { $result->return->persons = $data; } } /** * Fabrique une image informant d'une erreur lors de l'appel au WS. * Loading