@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | class BaseLanguageSetting extends MyActiveRecord implements SettingInterface { |
22 | 22 | |
23 | 23 | /** @var string $typeColumn the column containing setting type id */ |
24 | - protected static $typeColumn = "key"; |
|
24 | + protected static $typeColumn = "key"; |
|
25 | 25 | /** @var string */ |
26 | 26 | public $keyColumn = "key"; |
27 | 27 | |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | public function init() |
37 | 37 | { |
38 | 38 | parent::init(); |
39 | - if($this->insert()){ |
|
40 | - if(!$this->parent){ |
|
39 | + if ($this->insert()) { |
|
40 | + if (!$this->parent) { |
|
41 | 41 | throw new InvalidConfigException('Parent Model must be defined while initiating languages-settings'); |
42 | 42 | } |
43 | - if(!$this->parent instanceof WithLanguageInterface){ |
|
43 | + if (!$this->parent instanceof WithLanguageInterface) { |
|
44 | 44 | throw new InvalidConfigException('Parent Model must implement ModelWithLanguages'); |
45 | 45 | } |
46 | 46 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | [['language_id', 'value'], 'required'], |
58 | 58 | [['value'], 'string'], |
59 | 59 | [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::class, 'targetAttribute' => ['language_id' => 'language_id']], |
60 | - ], parent::rules()); |
|
60 | + ], parent::rules()); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,36 +66,36 @@ discard block |
||
66 | 66 | * @param string $key |
67 | 67 | * @return bool|static|array |
68 | 68 | */ |
69 | - public static function getSetting($parent, $language, $key){ |
|
69 | + public static function getSetting($parent, $language, $key) { |
|
70 | 70 | |
71 | 71 | /** @var TypeInterface $typeClass */ |
72 | 72 | $typeClass = static::$typeClass; |
73 | 73 | $type = $typeClass::getByKey($key); |
74 | 74 | |
75 | - if(!empty($type)){ |
|
75 | + if (!empty($type)) { |
|
76 | 76 | /** @var BaseLanguageSetting $model */ |
77 | 77 | $query = static::find(); |
78 | - if(!empty($parent)){ |
|
78 | + if (!empty($parent)) { |
|
79 | 79 | $query->andWhere([$parent::primaryKeySingle() =>$parent->primaryKey]); |
80 | 80 | } |
81 | - $model =$query->andWhere(['language_id'=>$language->primaryKey]) |
|
81 | + $model = $query->andWhere(['language_id'=>$language->primaryKey]) |
|
82 | 82 | ->andWhere([$typeClass::primaryKeySingle()=>$type->{$typeClass::primaryKeySingle()}]) |
83 | 83 | ->one(); |
84 | 84 | |
85 | - if(empty($model)){ |
|
85 | + if (empty($model)) { |
|
86 | 86 | /** @var BaseLanguageSetting $model */ |
87 | 87 | $model = \Yii::createObject(['class'=>static::class]); |
88 | 88 | $model->language_id = $language->primaryKey; |
89 | - if(!empty($parent)){ |
|
89 | + if (!empty($parent)) { |
|
90 | 90 | $model->{$parent::primaryKeySingle()} = $parent->primaryKey; |
91 | 91 | } |
92 | - $model->{$typeClass::primaryKeySingle()}=$type->{$typeClass::primaryKeySingle()}; |
|
92 | + $model->{$typeClass::primaryKeySingle()} = $type->{$typeClass::primaryKeySingle()}; |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | return $model; |
96 | 96 | } |
97 | 97 | |
98 | - throw new InvalidConfigException('Undefined type key: ' . $key); |
|
98 | + throw new InvalidConfigException('Undefined type key: '.$key); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param $key string |
136 | 136 | * @return static |
137 | 137 | */ |
138 | - public function findOneByKey($key){ |
|
138 | + public function findOneByKey($key) { |
|
139 | 139 | /** @var static $model */ |
140 | 140 | $model = static::find() |
141 | 141 | ->andWhere([static::$typeColumn => $key]) |