*/ | */ | ||||
public function actions() { | public function actions() { | ||||
return [ | return [ | ||||
'error' => [ | |||||
'class' => 'yii\web\ErrorAction', | |||||
], | |||||
'captcha' => [ | 'captcha' => [ | ||||
'class' => 'yii\captcha\CaptchaAction', | 'class' => 'yii\captcha\CaptchaAction', | ||||
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, | 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, | ||||
], | ], | ||||
]; | ]; | ||||
} | } | ||||
public function actionError() | |||||
{ | |||||
$exception = Yii::$app->errorHandler->exception; | |||||
if ($exception !== null) { | |||||
return $this->render('error', ['exception' => $exception]); | |||||
} | |||||
if( Yii::$app->getRequest()->getQueryParam('producer_not_found')) { | |||||
return $this->render('error-404-producer', ['exception' => $exception]); | |||||
} | |||||
} | |||||
public function actionIndex() { | public function actionIndex() { | ||||
<?php | |||||
$this->setTitle('Producteur introuvable') ; | |||||
?> | |||||
<div class="site-error"> | |||||
<h1>Producteur introuvable</h1> | |||||
<div class="alert alert-danger"> | |||||
Le producteur que vous recherchez est introuvable. | |||||
</div> | |||||
<p><?= Html::a("< Retour à l'accueil", ['site/index']) ?> - <?= Html::a("Liste des producteurs", ['site/producers']) ?></p> | |||||
</div> |
], | ], | ||||
], | ], | ||||
'errorHandler' => [ | 'errorHandler' => [ | ||||
'errorAction' => 'producer/error', | |||||
'errorAction' => 'site/error', | |||||
], | ], | ||||
'assetManager' => [ | 'assetManager' => [ | ||||
'bundles' => [ | 'bundles' => [ |
} | } | ||||
public function actions() { | public function actions() { | ||||
return [ | |||||
'error' => [ | |||||
'class' => 'yii\web\ErrorAction', | |||||
], | |||||
]; | |||||
return []; | |||||
} | } | ||||
public function getProducer() { | public function getProducer() { |
namespace producer\controllers; | namespace producer\controllers; | ||||
class SiteController extends ProducerBaseController { | class SiteController extends ProducerBaseController { | ||||
/** | /** | ||||
* @inheritdoc | * @inheritdoc | ||||
*/ | */ | ||||
public function actions() { | public function actions() { | ||||
return [ | return [ | ||||
'error' => [ | |||||
'class' => 'yii\web\ErrorAction', | |||||
], | |||||
'captcha' => [ | 'captcha' => [ | ||||
'class' => 'yii\captcha\CaptchaAction', | 'class' => 'yii\captcha\CaptchaAction', | ||||
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, | 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, | ||||
]; | ]; | ||||
} | } | ||||
public function actionError() | |||||
{ | |||||
$exception = Yii::$app->errorHandler->exception; | |||||
if ($exception !== null) { | |||||
if($exception->getMessage() == 'Établissement introuvable') { | |||||
Yii::$app->getResponse()->redirect(Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/error', 'producer_not_found' => true]))->send(); | |||||
return; | |||||
} | |||||
else { | |||||
return $this->render('error', ['exception' => $exception]); | |||||
} | |||||
} | |||||
} | |||||
/** | /** | ||||
* | * | ||||
* Affiche la page d'accueil des producteurs comprenant une image, une | * Affiche la page d'accueil des producteurs comprenant une image, une |
<?php | |||||
use yii\helpers\Html; | |||||
/* @var $this yii\web\View */ | |||||
/* @var $name string */ | |||||
/* @var $message string */ | |||||
/* @var $exception Exception */ | |||||
$this->title = $name; | |||||
?> | |||||
<div class="site-error"> | <div class="site-error"> | ||||
<h1><?= Html::encode($this->title) ?></h1> | |||||
<h1>Erreur <?= $exception->statusCode; ?></h1> | |||||
<div class="alert alert-danger"> | <div class="alert alert-danger"> | ||||
<?= nl2br(Html::encode($message)) ?> | |||||
<?= $exception->getMessage(); ?> | |||||
</div> | </div> | ||||
<p><?= Html::a("Retour à l'accueil", ['site/index']) ?></p> | |||||
</div> | |||||
</div> |