|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
-
-
-
- namespace common\helpers;
-
- use common\models\Producer;
-
- class GlobalParam
- {
-
- public function get($key)
- {
- if($key == 'producer'){
- return $this->getCurrentProducer();
- }else{
-
- return \Yii::$app->params[$key];
- }
- }
-
- public static function getCurrentProducer()
- {
- if(\Yii::$app->params['producer'] == false){
- \Yii::$app->params['producer'] = Producer::searchOne();
- }
- return \Yii::$app->params['producer'];
- }
-
-
-
- public static function getCurrentProducerId()
- {
- if(\Yii::$app->controller->module->id == 'app-backend') {
- if(!\Yii::$app->user->isGuest) {
- return Yii::$app->user->identity->id_producer ;
- }
- }
- else {
- return \Yii::$app->controller->getProducer()->id;
- }
-
- return false ;
- }
-
-
- }
|