|
- <?php
-
- namespace producer\controllers;
-
- class ProducerBaseController extends CommonController {
-
- var $producer ;
-
- /**
- * @inheritdoc
- */
- public function behaviors() {
- return [];
- }
-
- public function actions() {
- return [
- 'error' => [
- 'class' => 'yii\web\ErrorAction',
-
- ],
- ];
- }
-
- public function getProducer() {
- if($this->producer) {
- return $this->producer ;
- }
- else {
- $producer = Etablissement::findOne(['slug' => Yii::$app->getRequest()->getQueryParam('slug_producer')]) ;
- if($producer) {
- $this->producer = $producer ;
- return $this->producer ;
- }
- else {
- throw new \yii\web\HttpException(404, 'Établissement introuvable');
- }
- }
- }
- }
-
- ?>
|