Loading src/UnicaenLeocarte/Controller/IndexController.php +16 −10 Original line number Diff line number Diff line Loading @@ -2,11 +2,12 @@ namespace UnicaenLeocarte\Controller; use UnicaenLeocarte\Exception\ExtensionNotLoadedException; use UnicaenLeocarte\Exception\NotFoundException; use UnicaenLeocarte\Service\LeocarteServiceAwareInterface; use UnicaenLeocarte\Service\LeocarteServiceAwareTrait; use Zend\Http\PhpEnvironment\Response; use Zend\Mvc\Controller\AbstractActionController; use Zend\Stdlib\Exception\ExtensionNotLoadedException; class IndexController extends AbstractActionController implements LeocarteServiceAwareInterface { Loading @@ -25,17 +26,22 @@ class IndexController extends AbstractActionController implements LeocarteServic $id = $this->params()->fromRoute('id'); $nocache = (bool) (int) $this->params()->fromQuery('nocache', '0'); try { $autorise = $this->leocarteService->getDroitUtilisationPhoto($id); if ($autorise) { $content = $this->leocarteService->getPhoto($id); } else { try { $content = $this->leocarteService->createPhotoNonAutorisee(); } catch (ExtensionNotLoadedException $e) { } catch (NotFoundException $e) { // Requête infructueuse $content = ''; } catch (ExtensionNotLoadedException $e) { // Extension 'gd' non installée $content = ''; } /** @var Response $response */ Loading src/UnicaenLeocarte/Exception/ExtensionNotLoadedException.php 0 → 100644 +10 −0 Original line number Diff line number Diff line <?php namespace UnicaenLeocarte\Exception; use RuntimeException; class ExtensionNotLoadedException extends RuntimeException { } No newline at end of file src/UnicaenLeocarte/Exception/NotFoundException.php 0 → 100644 +10 −0 Original line number Diff line number Diff line <?php namespace UnicaenLeocarte\Exception; use RuntimeException; class NotFoundException extends RuntimeException { } No newline at end of file src/UnicaenLeocarte/Service/LeocarteService.php +10 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace UnicaenLeocarte\Service; use RuntimeException; use UnicaenLeocarte\Exception\NotFoundException; use UnicaenLeocarte\Service\Soap\LeocarteSoapClientAwareInterface; use UnicaenLeocarte\Service\Soap\LeocarteSoapClientAwareTrait; use Zend\Stdlib\Exception\ExtensionNotLoadedException; Loading @@ -27,6 +29,10 @@ class LeocarteService implements LeocarteSoapClientAwareInterface { $result = $this->leocarteSoapClient->getDroitUtilisationPhoto($identifiant); if (! isset($result->return->persons)) { throw new NotFoundException("Requête infructueuse"); } $string = $result->return->persons->data->value->stringValue; return $string === self::UTILISATION_PHOTO_AUTORISEE; Loading @@ -42,6 +48,10 @@ class LeocarteService implements LeocarteSoapClientAwareInterface /** @var \stdClass $result */ $result = $this->leocarteSoapClient->getPhoto($identifiant); if (! isset($result->return->persons)) { throw new NotFoundException("Requête infructueuse"); } // c'est le contenu "binaire" de la photo qui est retourné par le WS $imgData = $result->return->persons->data->value->imageValue; Loading @@ -54,7 +64,6 @@ class LeocarteService implements LeocarteSoapClientAwareInterface * @param int $width * @param int $height * @return string Contenu binaire de l'image * @throws ExtensionNotLoadedException Si l'extension gd n'est pas activée */ public function createPhotoNonAutorisee($width = 100, $height = 120) { Loading Loading
src/UnicaenLeocarte/Controller/IndexController.php +16 −10 Original line number Diff line number Diff line Loading @@ -2,11 +2,12 @@ namespace UnicaenLeocarte\Controller; use UnicaenLeocarte\Exception\ExtensionNotLoadedException; use UnicaenLeocarte\Exception\NotFoundException; use UnicaenLeocarte\Service\LeocarteServiceAwareInterface; use UnicaenLeocarte\Service\LeocarteServiceAwareTrait; use Zend\Http\PhpEnvironment\Response; use Zend\Mvc\Controller\AbstractActionController; use Zend\Stdlib\Exception\ExtensionNotLoadedException; class IndexController extends AbstractActionController implements LeocarteServiceAwareInterface { Loading @@ -25,17 +26,22 @@ class IndexController extends AbstractActionController implements LeocarteServic $id = $this->params()->fromRoute('id'); $nocache = (bool) (int) $this->params()->fromQuery('nocache', '0'); try { $autorise = $this->leocarteService->getDroitUtilisationPhoto($id); if ($autorise) { $content = $this->leocarteService->getPhoto($id); } else { try { $content = $this->leocarteService->createPhotoNonAutorisee(); } catch (ExtensionNotLoadedException $e) { } catch (NotFoundException $e) { // Requête infructueuse $content = ''; } catch (ExtensionNotLoadedException $e) { // Extension 'gd' non installée $content = ''; } /** @var Response $response */ Loading
src/UnicaenLeocarte/Exception/ExtensionNotLoadedException.php 0 → 100644 +10 −0 Original line number Diff line number Diff line <?php namespace UnicaenLeocarte\Exception; use RuntimeException; class ExtensionNotLoadedException extends RuntimeException { } No newline at end of file
src/UnicaenLeocarte/Exception/NotFoundException.php 0 → 100644 +10 −0 Original line number Diff line number Diff line <?php namespace UnicaenLeocarte\Exception; use RuntimeException; class NotFoundException extends RuntimeException { } No newline at end of file
src/UnicaenLeocarte/Service/LeocarteService.php +10 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace UnicaenLeocarte\Service; use RuntimeException; use UnicaenLeocarte\Exception\NotFoundException; use UnicaenLeocarte\Service\Soap\LeocarteSoapClientAwareInterface; use UnicaenLeocarte\Service\Soap\LeocarteSoapClientAwareTrait; use Zend\Stdlib\Exception\ExtensionNotLoadedException; Loading @@ -27,6 +29,10 @@ class LeocarteService implements LeocarteSoapClientAwareInterface { $result = $this->leocarteSoapClient->getDroitUtilisationPhoto($identifiant); if (! isset($result->return->persons)) { throw new NotFoundException("Requête infructueuse"); } $string = $result->return->persons->data->value->stringValue; return $string === self::UTILISATION_PHOTO_AUTORISEE; Loading @@ -42,6 +48,10 @@ class LeocarteService implements LeocarteSoapClientAwareInterface /** @var \stdClass $result */ $result = $this->leocarteSoapClient->getPhoto($identifiant); if (! isset($result->return->persons)) { throw new NotFoundException("Requête infructueuse"); } // c'est le contenu "binaire" de la photo qui est retourné par le WS $imgData = $result->return->persons->data->value->imageValue; Loading @@ -54,7 +64,6 @@ class LeocarteService implements LeocarteSoapClientAwareInterface * @param int $width * @param int $height * @return string Contenu binaire de l'image * @throws ExtensionNotLoadedException Si l'extension gd n'est pas activée */ public function createPhotoNonAutorisee($width = 100, $height = 120) { Loading