This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace app\models; |
||
4 | |||
5 | use Yii; |
||
6 | use yii\caching\TagDependency; |
||
7 | use yii\db\ActiveRecord; |
||
8 | use yii\db\Query; |
||
9 | use yii\helpers\ArrayHelper; |
||
10 | |||
11 | /** |
||
12 | * This is the model class for table "property_handler". |
||
13 | * |
||
14 | * @property integer $id |
||
15 | * @property string $name |
||
16 | * @property string $frontend_render_view |
||
17 | * @property string $frontend_edit_view |
||
18 | * @property string $backend_render_view |
||
19 | * @property string $backend_edit_view |
||
20 | * @property string $handler_class_name |
||
21 | */ |
||
22 | class PropertyHandler extends ActiveRecord |
||
23 | { |
||
24 | private static $identity_map = []; |
||
25 | private static $select_array_cache = null; |
||
26 | private static $map_name_to_id = []; |
||
27 | |||
28 | public function behaviors() |
||
29 | { |
||
30 | return [ |
||
31 | [ |
||
32 | 'class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className(), |
||
0 ignored issues
–
show
|
|||
33 | ], |
||
34 | ]; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @inheritdoc |
||
39 | */ |
||
40 | public static function tableName() |
||
41 | { |
||
42 | return '{{%property_handler}}'; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @inheritdoc |
||
47 | */ |
||
48 | public function rules() |
||
49 | { |
||
50 | return [ |
||
51 | [ |
||
52 | ['name', 'frontend_render_view', 'frontend_edit_view', 'backend_render_view', |
||
53 | 'backend_edit_view', 'handler_class_name'], |
||
54 | 'required' |
||
55 | ], |
||
56 | [ |
||
57 | ['name', 'frontend_render_view', 'frontend_edit_view', 'backend_render_view', |
||
58 | 'backend_edit_view', 'handler_class_name'], |
||
59 | 'string' |
||
60 | ] |
||
61 | ]; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @inheritdoc |
||
66 | */ |
||
67 | public function attributeLabels() |
||
68 | { |
||
69 | return [ |
||
70 | 'id' => Yii::t('app', 'ID'), |
||
71 | 'name' => Yii::t('app', 'Name'), |
||
72 | 'frontend_render_view' => Yii::t('app', 'Frontend Render View'), |
||
73 | 'frontend_edit_view' => Yii::t('app', 'Frontend Edit View'), |
||
74 | 'backend_render_view' => Yii::t('app', 'Backend Render View'), |
||
75 | 'backend_edit_view' => Yii::t('app', 'Backend Edit View'), |
||
76 | 'handler_class_name' => Yii::t('app', 'Handler Class Name'), |
||
77 | ]; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Возвращает модель по ID с использованием IdentityMap |
||
82 | */ |
||
83 | View Code Duplication | public static function findById($id) |
|
84 | { |
||
85 | if (!isset(static::$identity_map[$id])) { |
||
86 | static::$identity_map[$id] = Yii::$app->cache->get('PropertyHandler: ' . $id); |
||
87 | if (static::$identity_map[$id] === false) { |
||
88 | static::$identity_map[$id] = PropertyHandler::findOne($id); |
||
89 | if (static::$identity_map[$id] !== null) { |
||
90 | Yii::$app->cache->set( |
||
91 | 'PropertyHandler: ' . $id, |
||
92 | static::$identity_map[$id], |
||
93 | 86400, |
||
94 | new TagDependency( |
||
95 | [ |
||
96 | 'tags' => [ |
||
97 | \devgroup\TagDependencyHelper\ActiveRecordHelper::getObjectTag(static::className(), $id), |
||
0 ignored issues
–
show
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. ![]() |
|||
98 | ], |
||
99 | ] |
||
100 | ) |
||
101 | ); |
||
102 | } |
||
103 | } |
||
104 | } |
||
105 | return static::$identity_map[$id]; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Возвращает список всех объектов |
||
110 | * Ключ - ID |
||
111 | * Значение - name |
||
112 | * Используется для фильтрации в таблицах и выборе объекта в форме |
||
113 | */ |
||
114 | View Code Duplication | public static function getSelectArray() |
|
115 | { |
||
116 | if (static::$select_array_cache === null) { |
||
117 | static::$select_array_cache = Yii::$app->cache->get('PropertyHandlersList'); |
||
118 | if (static::$select_array_cache === false) { |
||
119 | $rows = (new Query()) |
||
120 | ->select('id, name') |
||
121 | ->from(PropertyHandler::tableName()) |
||
122 | ->all(); |
||
123 | static::$select_array_cache = ArrayHelper::map($rows, 'id', 'name'); |
||
124 | Yii::$app->cache->set( |
||
125 | 'PropertyHandlersList', |
||
126 | static::$select_array_cache, |
||
127 | 86400, |
||
128 | new TagDependency( |
||
129 | [ |
||
130 | 'tags' => [ |
||
131 | \devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag(static::className()), |
||
0 ignored issues
–
show
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. ![]() |
|||
132 | ], |
||
133 | ] |
||
134 | ) |
||
135 | ); |
||
136 | } |
||
137 | } |
||
138 | return static::$select_array_cache; |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @param $name |
||
143 | * @return null|int |
||
144 | */ |
||
145 | public static function findByName($name) |
||
146 | { |
||
147 | if (empty(static::$map_name_to_id)) { |
||
148 | $cache_key = 'PropertyHandler:MapToId'; |
||
149 | static::$map_name_to_id = Yii::$app->cache->get($cache_key); |
||
150 | if (false === static::$map_name_to_id) { |
||
151 | $query = static::find()->asArray()->all(); |
||
152 | foreach ($query as $row) { |
||
153 | static::$map_name_to_id[$row['name']] = intval($row['id']); |
||
154 | } |
||
155 | Yii::$app->cache->set( |
||
156 | $cache_key, |
||
157 | static::$map_name_to_id, |
||
158 | 0, |
||
159 | new TagDependency( |
||
160 | [ |
||
161 | 'tags' => [ |
||
162 | \devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag(static::className()), |
||
0 ignored issues
–
show
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. ![]() |
|||
163 | ] |
||
164 | ] |
||
165 | ) |
||
166 | ); |
||
167 | } |
||
168 | } |
||
169 | |||
170 | if (isset(static::$map_name_to_id[$name])) { |
||
171 | return static::$map_name_to_id[$name]; |
||
172 | } |
||
173 | |||
174 | return null; |
||
175 | } |
||
176 | } |
||
177 |
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.