1 | <?php |
||
2 | /** |
||
3 | * Minify plugin for Craft CMS |
||
4 | * |
||
5 | * @link https://nystudio107.com/ |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
6 | * @copyright Copyright (c) nystudio107 |
||
0 ignored issues
–
show
|
|||
7 | * @license MIT License https://opensource.org/licenses/MIT |
||
8 | */ |
||
0 ignored issues
–
show
|
|||
9 | |||
10 | namespace nystudio107\minify; |
||
11 | |||
12 | use Craft; |
||
13 | use craft\base\Model; |
||
14 | use craft\base\Plugin; |
||
15 | use nystudio107\minify\models\Settings; |
||
16 | use nystudio107\minify\services\ServicesTrait; |
||
17 | use nystudio107\minify\twigextensions\MinifyTwigExtension; |
||
18 | |||
19 | /** |
||
20 | * Class Minify |
||
21 | * |
||
22 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
23 | * @package Minify |
||
0 ignored issues
–
show
|
|||
24 | * @since 5.0.0 |
||
0 ignored issues
–
show
|
|||
25 | * |
||
26 | * @method Settings getSettings() |
||
27 | */ |
||
0 ignored issues
–
show
|
|||
28 | class Minify extends Plugin |
||
29 | { |
||
30 | // Traits |
||
31 | // ========================================================================= |
||
32 | |||
33 | use ServicesTrait; |
||
34 | |||
35 | // Static Properties |
||
36 | // ========================================================================= |
||
37 | /** |
||
0 ignored issues
–
show
|
|||
38 | * @var Minify |
||
39 | */ |
||
40 | public static Minify $plugin; |
||
41 | |||
42 | // Public Properties |
||
43 | // ========================================================================= |
||
44 | |||
45 | /** |
||
0 ignored issues
–
show
|
|||
46 | * @var string |
||
47 | */ |
||
48 | public string $schemaVersion = '1.0.0'; |
||
49 | |||
50 | /** |
||
0 ignored issues
–
show
|
|||
51 | * @var bool |
||
52 | */ |
||
53 | public bool $hasCpSettings = false; |
||
54 | /** |
||
0 ignored issues
–
show
|
|||
55 | * @var bool |
||
56 | */ |
||
57 | public bool $hasCpSection = false; |
||
58 | |||
59 | // Public Methods |
||
60 | // ========================================================================= |
||
61 | |||
62 | /** |
||
0 ignored issues
–
show
|
|||
63 | * @inheritdoc |
||
64 | */ |
||
0 ignored issues
–
show
|
|||
65 | public function init(): void |
||
66 | { |
||
67 | parent::init(); |
||
68 | self::$plugin = $this; |
||
69 | $this->name = $this->getName(); |
||
70 | |||
71 | // Add in our Twig extensions |
||
72 | Craft::$app->view->registerTwigExtension(new MinifyTwigExtension()); |
||
73 | |||
74 | Craft::info( |
||
75 | Craft::t( |
||
76 | 'minify', |
||
77 | '{name} plugin loaded', |
||
78 | ['name' => $this->name] |
||
79 | ), |
||
80 | __METHOD__ |
||
81 | ); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Returns the user-facing name of the plugin, which can override the name |
||
86 | * in composer.json |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getName(): string |
||
91 | { |
||
92 | return Craft::t('minify', 'Minify'); |
||
93 | } |
||
94 | |||
95 | // Protected Methods |
||
96 | // ========================================================================= |
||
97 | |||
98 | /** |
||
0 ignored issues
–
show
|
|||
99 | * @inerhitDoc |
||
100 | */ |
||
0 ignored issues
–
show
|
|||
101 | protected function createSettingsModel(): ?Model |
||
102 | { |
||
103 | return new Settings(); |
||
104 | } |
||
105 | } |
||
106 |