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\console\controllers; |
||
13 | |||
14 | use Craft; |
||
15 | |||
16 | use nystudio107\retour\Retour; |
||
17 | use yii\console\Controller; |
||
18 | |||
19 | /** |
||
20 | * Retour Stats command |
||
21 | * |
||
22 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
23 | * @package Retour |
||
0 ignored issues
–
show
|
|||
24 | * @since 3.0.0 |
||
0 ignored issues
–
show
|
|||
25 | */ |
||
0 ignored issues
–
show
|
|||
26 | class StatsController extends Controller |
||
27 | { |
||
28 | // Public Properties |
||
29 | // ========================================================================= |
||
30 | |||
31 | /** |
||
0 ignored issues
–
show
|
|||
32 | * @var null|int |
||
33 | */ |
||
34 | public $limit; |
||
35 | |||
36 | // Protected Properties |
||
37 | // ========================================================================= |
||
38 | |||
39 | /** |
||
0 ignored issues
–
show
|
|||
40 | * @var bool|array |
||
0 ignored issues
–
show
|
|||
41 | */ |
||
42 | protected $allowAnonymous = [ |
||
43 | ]; |
||
44 | |||
45 | // Public Methods |
||
46 | // ========================================================================= |
||
47 | |||
48 | /** |
||
0 ignored issues
–
show
|
|||
49 | * @param string $actionID |
||
0 ignored issues
–
show
|
|||
50 | * |
||
51 | * @return array|string[] |
||
52 | */ |
||
53 | public function options($actionID): array |
||
54 | { |
||
55 | return [ |
||
56 | 'limit', |
||
57 | ]; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Trim the Retour statistics database table |
||
62 | * |
||
63 | * @return int |
||
64 | */ |
||
65 | public function actionTrim(): int |
||
66 | { |
||
67 | echo Craft::t('retour', 'Trimming statistics') . PHP_EOL; |
||
68 | $affectedRows = Retour::$plugin->statistics->trimStatistics($this->limit); |
||
69 | echo Craft::t( |
||
70 | 'retour', |
||
0 ignored issues
–
show
|
|||
71 | 'Trimmed {rows} from retour_stats table', |
||
0 ignored issues
–
show
|
|||
72 | ['rows' => $affectedRows] |
||
0 ignored issues
–
show
|
|||
73 | ) . PHP_EOL; |
||
0 ignored issues
–
show
|
|||
74 | |||
75 | return 0; |
||
76 | } |
||
77 | |||
78 | // Protected Methods |
||
79 | // ========================================================================= |
||
80 | } |
||
81 |