You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
915B

  1. <?php
  2. namespace producer\controllers;
  3. class ProducerBaseController extends CommonController {
  4. var $producer ;
  5. /**
  6. * @inheritdoc
  7. */
  8. public function behaviors() {
  9. return [];
  10. }
  11. public function actions() {
  12. return [
  13. 'error' => [
  14. 'class' => 'yii\web\ErrorAction',
  15. ],
  16. ];
  17. }
  18. public function getProducer() {
  19. if($this->producer) {
  20. return $this->producer ;
  21. }
  22. else {
  23. $producer = Etablissement::findOne(['slug' => Yii::$app->getRequest()->getQueryParam('slug_producer')]) ;
  24. if($producer) {
  25. $this->producer = $producer ;
  26. return $this->producer ;
  27. }
  28. else {
  29. throw new \yii\web\HttpException(404, 'Établissement introuvable');
  30. }
  31. }
  32. }
  33. }
  34. ?>