Commit ec574568 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Image "erreur survenue" si erreur lors de l'appel au WS.

Prise en compte des options SOAP 'proxy_host' et 'proxy_port' (requises en prod).
parent 1a635763
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace UnicaenLeocarte\Controller;

use UnicaenLeocarte\Exception\ExtensionNotLoadedException;
use UnicaenLeocarte\Exception\NotFoundException;
use UnicaenLeocarte\Exception\RuntimeException;
use UnicaenLeocarte\Service\Photo\PhotoServiceAwareInterface;
use UnicaenLeocarte\Service\Photo\PhotoServiceAwareTrait;
use Zend\Http\PhpEnvironment\Response;
@@ -50,17 +51,22 @@ class IndexController extends AbstractActionController implements PhotoServiceAw
                }
            }
        }
        catch (NotFoundException $e) {
        catch (NotFoundException $nfe) {
            // Requête infructueuse.
            // On tente de fabriquer une image informative...
            try {
                $content = $this->photoService->createPhotoIntrouvable();
            }
            catch (ExtensionNotLoadedException $e) {
            catch (ExtensionNotLoadedException $enle) {
                // Extension 'gd' non installée
                $content = '';
            }
        }
        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();
        }

        /** @var Response $response */
        $response = $this->getResponse();
+0 −2
Original line number Diff line number Diff line
@@ -2,8 +2,6 @@

namespace UnicaenLeocarte\Exception;

use RuntimeException;

class ExtensionNotLoadedException extends RuntimeException
{

+0 −2
Original line number Diff line number Diff line
@@ -2,8 +2,6 @@

namespace UnicaenLeocarte\Exception;

use RuntimeException;

class NotFoundException extends RuntimeException
{

+8 −0
Original line number Diff line number Diff line
<?php

namespace UnicaenLeocarte\Exception;

class RuntimeException extends \RuntimeException
{

}
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
@@ -62,6 +62,20 @@ class PhotoService implements SoapClientAwareInterface
        return $imgData;
    }

    /**
     * Fabrique une image informant d'une erreur lors de l'appel au WS.
     *
     * @return string Contenu binaire de l'image générée
     */
    public function createPhotoErreur()
    {
        return $this->_createImage(
            "            |" .
            " Une erreur |" .
            "     est    |" .
            "   survenue ");
    }

    /**
     * Fabrique une image informant que la photo est introuvable.
     *
Loading