|
123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?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');
- }
- }
- }
- }
-
- ?>
|