public function init() { parent::init(); }
/** * Get dialog image * * @return array */ public function getInterlocutorImage() { $users = $this->innerMessageUsers; if (empty($users)) { throw new \BadMethodCallException(); } $image = []; $userAvatar = Yii::$app->getSession()->get(Chat::getSessionName()) . Chat::$defaultUserAvatar; $avatarMethod = $this->pchatSettings['userAvatarMethod']; foreach ($users as $user) { if ($user->user_id != Yii::$app->user->id) { if ($this->pchatSettings['userModel'] == $avatarMethod['class']) { $tempAvatar = $this->user->{$avatarMethod}['method']; } else { $tempAvatar = $this->user->{$avatarMethod}['relation']->{$avatarMethod}['method']; } if (!empty($tempAvatar)) { $userAvatar = $tempAvatar; } $image[] = $userAvatar; } } return $image; }
/** * Get user avatar * @return string */ public function getUserAvatar() { $userAvatar = Yii::$app->getSession()->get(Chat::getSessionName()) . Chat::$defaultUserAvatar; if (!empty($this->pchatSettings['userAvatarMethod'])) { $avatarMethod = $this->pchatSettings['userAvatarMethod']; if ($this->pchatSettings['userModel'] == $avatarMethod['class']) { $tempAvatar = $this->user->{$avatarMethod}['method']; } else { $tempAvatar = $this->user->{$avatarMethod}['relation']->{$avatarMethod}['method']; } if (!empty($tempAvatar)) { $userAvatar = $tempAvatar; } } return $userAvatar; }