LanguageTranslation   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A attributeLabels() 0 9 1
A rules() 0 10 1
A findTranslations() 0 9 1
A tableName() 0 3 1
1
<?php
2
3
namespace andmemasin\language\models;
4
5
use Yii;
6
use andmemasin\myabstract\MyActiveRecord;
7
8
/**
9
 * This is the model class for table "language_translation".
10
 *
11
 * @property integer $language_translation_id
12
 * @property integer $language_id
13
 * @property string $model_class
14
 * @property integer $model_id
15
 * @property string $model_field_name
16
 * @property string $value
17
 */
18
class LanguageTranslation extends MyActiveRecord
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public static function tableName()
24
    {
25
        return 'language_translation';
26
    }
27
    
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function rules()
33
    {
34
        return array_merge([
35
            [['language_id', 'model_class', 'model_id', 'value','model_field_name'], 'required'],
36
            [['language_id', 'model_id'], 'integer'],
37
            [['value'], 'string'],
38
            [['model_class'], 'string', 'max' => 255],
39
            [['model_field_name'], 'string', 'max' => 128],
40
            [['language_id'], 'exist', 'skipOnError' => true, 'targetClass' => Language::class, 'targetAttribute' => ['language_id' => 'language_id']]
41
        ],  parent::rules());
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function attributeLabels()
48
    {
49
        return [
50
            'language_translation_id' => Yii::t('app', 'Language Translation ID'),
51
            'language_id' => Yii::t('app', 'Language ID'),
52
            'model_class' => Yii::t('app', 'Model Class'),
53
            'model_field_name' => Yii::t('app', 'Model field name'),
54
            'model_id' => Yii::t('app', 'Model ID'),
55
            'value' => Yii::t('app', 'Value'),
56
        ];
57
    }
58
59
    /**
60
     * Translations in all available languages indexed by language_id
61
     * @param string $class
62
     * @param integer $id
63
     * @param string $column
64
     * @return LanguageTranslation[]
65
     * @deprecated
66
     */
67
    public static function findTranslations($class, $id, $column){
68
        /** @var LanguageTranslation $model */
69
        $query = self::find()->andWhere([
70
            'model_class'=>$class,
71
            'model_id'=>$id,
72
            'model_field_name'=>$column,])
73
            ->indexBy('language_id');
74
75
        return $query->all();
76
    }
77
78
79
}
80