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.

46 lines
1009B

  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::find()
  24. ->with('contact')
  25. ->where(['slug' => Yii::$app->getRequest()->getQueryParam('slug_producer')])
  26. ->one() ;
  27. if($producer) {
  28. $this->producer = $producer ;
  29. return $this->producer ;
  30. }
  31. else {
  32. throw new \yii\web\HttpException(404, 'Établissement introuvable');
  33. }
  34. }
  35. }
  36. }
  37. ?>