'components' => [
'assetManager' => [
'linkAssets' => true,
'appendTimestamp' => true,
],
'config' => [ // сам компонент прописываем
'class' => 'app\components\Config',
],
'SMSCenter' => [
'class' => 'integready\smsc\SMSCenter',
'login' => 'citycenter',
'password' => Yii::$app->config->siteName,
'useSSL' => false,
'options' => [
'sender' => 'ParserN', // имя отправителя
],
],
<?php
namespace app\components;
use Yii;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
class Config extends Component {
private $_attributes;
/**
* @inheritdoc
*/
public function init() {
parent::init();
$this->_attributes = ArrayHelper::map(\app\models\Config::find()->where(['=', 'id_company', Yii::$app->user->identity->id_company])
->all(), 'name', 'val');
}
public function __get($name) {
if (array_key_exists($name, $this->_attributes))
return $this->_attributes[$name];
return parent::__get($name);
}
}