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