GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DynamicContent::attributeLabels()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
dl 17
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace app\models;
4
5
use devgroup\TagDependencyHelper\ActiveRecordHelper;
6
use Yii;
7
use yii\data\ActiveDataProvider;
8
use yii\db\ActiveRecord;
9
10
/**
11
 * This is the model class for table "dynamic_content".
12
 *
13
 * @property integer $id
14
 * @property string $route
15
 * @property string $name
16
 * @property string $content_block_name
17
 * @property string $announce
18
 * @property string $content
19
 * @property string $title
20
 * @property string $h1
21
 * @property string $meta_description
22
 * @property integer $apply_if_last_category_id
23
 * @property string $apply_if_params
24
 * @property integer $object_id
25
 */
26
class DynamicContent extends ActiveRecord
27
{
28
    private static $identity_map = [];
29
    /**
30
     * @inheritdoc
31
     */
32
    public static function tableName()
33
    {
34
        return '{{%dynamic_content}}';
35
    }
36
37
    public function behaviors()
38
    {
39
        return [
40
            [
41
                'class' => ActiveRecordHelper::className(),
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
42
            ],
43
        ];
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function rules()
50
    {
51
        return [
52
            [['route', 'name', 'announce', 'content', 'title', 'h1', 'meta_description', 'apply_if_params'], 'string'],
53
            [
54
                [
55
                    'apply_if_last_category_id',
56
                    'object_id'
57
                ],
58
                'integer'
59
            ],
60
            [
61
                ['apply_if_last_category_id'],
62
                'required',
63
                'when' => function ($model) {
64
                    return $model->route === 'shop/product/list';
65
                },
66
                'whenClient' => "function (attribute, value) {
67
                    return $('#dynamiccontent-route').val() === 'shop/product/list';
68
                }"
69
            ],
70
            [['content_block_name'], 'string', 'max' => 80],
71
            [['content_block_name'], 'default', 'value' => 'bottom_text'],
72
            [['route'], 'default', 'value' => 'shop/product/list'],
73
        ];
74
    }
75
76
    /**
77
     * @inheritdoc
78
     */
79 View Code Duplication
    public function attributeLabels()
80
    {
81
        return [
82
            'id' => Yii::t('app', 'ID'),
83
            'route' => Yii::t('app', 'Route'),
84
            'name' => Yii::t('app', 'Name'),
85
            'content_block_name' => Yii::t('app', 'Content Block Name'),
86
            'announce' => Yii::t('app', 'Announce'),
87
            'content' => Yii::t('app', 'Content'),
88
            'title' => Yii::t('app', 'Title'),
89
            'h1' => Yii::t('app', 'H1'),
90
            'meta_description' => Yii::t('app', 'Meta Description'),
91
            'apply_if_last_category_id' => Yii::t('app', 'Apply If Last Category ID'),
92
            'apply_if_params' => Yii::t('app', 'Apply If Params'),
93
            'object_id' => Yii::t('app', 'Object'),
94
        ];
95
    }
96
97
    /**
98
     * Search tasks
99
     * @param $params
100
     * @return ActiveDataProvider
101
     */
102
    public function search($params)
103
    {
104
        /* @var $query \yii\db\ActiveQuery */
105
        $query = self::find();
106
        $dataProvider = new ActiveDataProvider(
107
            [
108
                'query' => $query,
109
                'pagination' => [
110
                    'pageSize' => 10,
111
                ],
112
            ]
113
        );
114
        if (!($this->load($params))) {
115
            return $dataProvider;
116
        }
117
        $query->andFilterWhere(['id' => $this->id]);
118
        $query->andFilterWhere(['like', 'name', $this->name]);
119
        $query->andFilterWhere(['like', 'route', $this->route]);
120
        $query->andFilterWhere(['like', 'title', $this->title]);
121
        $query->andFilterWhere(['like', 'content_block_name', $this->content_block_name]);
122
        $query->andFilterWhere(['like', 'h1', $this->h1]);
123
        $query->andFilterWhere(['like', 'meta_description', $this->meta_description]);
124
        return $dataProvider;
125
    }
126
127
    /**
128
     * Finds model by id using identity map
129
     * @param $id
130
     * @return mixed
131
     */
132
    public static function findById($id)
133
    {
134
        if (!isset(static::$identity_map[$id])) {
135
            static::$identity_map[$id] = DynamicContent::findOne($id);
136
        }
137
        return static::$identity_map[$id];
138
    }
139
}
140