1 | <?php |
||
2 | /** |
||
3 | * Retour plugin for Craft CMS |
||
4 | * |
||
5 | * Retour allows you to intelligently redirect legacy URLs, so that you don't |
||
6 | * lose SEO value when rebuilding & restructuring a website |
||
7 | * |
||
8 | * @link https://nystudio107.com/ |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
9 | * @copyright Copyright (c) 2018 nystudio107 |
||
0 ignored issues
–
show
|
|||
10 | */ |
||
0 ignored issues
–
show
|
|||
11 | |||
12 | namespace nystudio107\retour\models; |
||
13 | |||
14 | use nystudio107\retour\validators\DbStringValidator; |
||
15 | use yii\behaviors\AttributeTypecastBehavior; |
||
16 | |||
17 | /** |
||
0 ignored issues
–
show
|
|||
18 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
19 | * @package Retour |
||
0 ignored issues
–
show
|
|||
20 | * @since 3.0.0 |
||
0 ignored issues
–
show
|
|||
21 | */ |
||
0 ignored issues
–
show
|
|||
22 | class Stats extends DbModel |
||
23 | { |
||
24 | // Public Properties |
||
25 | // ========================================================================= |
||
26 | |||
27 | /** |
||
0 ignored issues
–
show
|
|||
28 | * @var int |
||
29 | */ |
||
30 | public int $id = 0; |
||
31 | |||
32 | /** |
||
0 ignored issues
–
show
|
|||
33 | * @var null|int |
||
34 | */ |
||
35 | public ?int $siteId = null; |
||
36 | |||
37 | /** |
||
0 ignored issues
–
show
|
|||
38 | * @var string |
||
39 | */ |
||
40 | public string $redirectSrcUrl = ''; |
||
41 | |||
42 | /** |
||
0 ignored issues
–
show
|
|||
43 | * @var string |
||
44 | */ |
||
45 | public string $referrerUrl = ''; |
||
46 | |||
47 | /** |
||
0 ignored issues
–
show
|
|||
48 | * @var string |
||
49 | */ |
||
50 | public string $remoteIp = ''; |
||
51 | |||
52 | /** |
||
0 ignored issues
–
show
|
|||
53 | * @var string |
||
54 | */ |
||
55 | public string $userAgent = ''; |
||
56 | |||
57 | /** |
||
0 ignored issues
–
show
|
|||
58 | * @var string |
||
59 | */ |
||
60 | public string $exceptionMessage = ''; |
||
61 | |||
62 | /** |
||
0 ignored issues
–
show
|
|||
63 | * @var string |
||
64 | */ |
||
65 | public string $exceptionFilePath = ''; |
||
66 | |||
67 | /** |
||
0 ignored issues
–
show
|
|||
68 | * @var int |
||
69 | */ |
||
70 | public int $exceptionFileLine = 0; |
||
71 | |||
72 | /** |
||
0 ignored issues
–
show
|
|||
73 | * @var int |
||
74 | */ |
||
75 | public int $hitCount = 0; |
||
76 | |||
77 | /** |
||
0 ignored issues
–
show
|
|||
78 | * @var string |
||
79 | */ |
||
80 | public string $hitLastTime = ''; |
||
81 | |||
82 | /** |
||
0 ignored issues
–
show
|
|||
83 | * @var int |
||
84 | */ |
||
85 | public int $handledByRetour = 0; |
||
86 | |||
87 | // Public Methods |
||
88 | // ========================================================================= |
||
89 | |||
90 | /** |
||
0 ignored issues
–
show
|
|||
91 | * @inheritdoc |
||
92 | */ |
||
0 ignored issues
–
show
|
|||
93 | public function rules(): array |
||
94 | { |
||
95 | return [ |
||
96 | ['id', 'integer'], |
||
97 | ['siteId', 'integer'], |
||
98 | ['siteId', 'default', 'value' => null], |
||
99 | [ |
||
100 | [ |
||
101 | 'redirectSrcUrl', |
||
102 | 'userAgent', |
||
103 | 'exceptionMessage', |
||
104 | 'exceptionFilePath', |
||
105 | ], |
||
106 | DbStringValidator::class, |
||
107 | 'max' => 255, |
||
108 | ], |
||
109 | [ |
||
110 | [ |
||
111 | 'redirectSrcUrl', |
||
112 | 'userAgent', |
||
113 | 'exceptionMessage', |
||
114 | 'exceptionFilePath', |
||
115 | ], |
||
116 | 'string', |
||
117 | ], |
||
118 | [ |
||
119 | [ |
||
120 | 'redirectSrcUrl', |
||
121 | 'userAgent', |
||
122 | 'exceptionMessage', |
||
123 | 'exceptionFilePath', |
||
124 | ], |
||
125 | 'default', |
||
126 | 'value' => '', |
||
127 | ], |
||
128 | ['exceptionFileLine', 'integer'], |
||
129 | ['exceptionFileLine', 'default', 'value' => 0], |
||
130 | ['referrerUrl', DbStringValidator::class, 'max' => 2000], |
||
131 | ['referrerUrl', 'string'], |
||
132 | ['referrerUrl', 'default', 'value' => ''], |
||
133 | ['remoteIp', DbStringValidator::class, 'max' => 45], |
||
134 | ['remoteIp', 'string'], |
||
135 | ['remoteIp', 'default', 'value' => ''], |
||
136 | ['hitCount', 'integer'], |
||
137 | ['hitCount', 'default', 'value' => 0], |
||
138 | ['hitLastTime', 'safe'], |
||
139 | ['handledByRetour', 'integer', 'min' => 0, 'max' => 1], |
||
140 | ['handledByRetour', 'default', 'value' => 0], |
||
141 | ]; |
||
142 | } |
||
143 | |||
144 | /** |
||
0 ignored issues
–
show
|
|||
145 | * @return array |
||
146 | */ |
||
147 | public function behaviors(): array |
||
148 | { |
||
149 | return [ |
||
150 | 'typecast' => [ |
||
151 | 'class' => AttributeTypecastBehavior::class, |
||
152 | // 'attributeTypes' will be composed automatically according to `rules()` |
||
153 | ], |
||
154 | ]; |
||
155 | } |
||
156 | } |
||
157 |