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