-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.php
executable file
·73 lines (64 loc) · 1.65 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Bas les masques ! plugin for Craft CMS 3.x
*
* Helps you detect if a user is being impersonated and get the originally signed in user
*
* @link https://github.com/nstCactus
* @copyright Copyright (c) 2021 nstCactus
*/
namespace nstcactus\baslesmasques;
use craft\base\Model;
use nstcactus\baslesmasques\models\Settings;
use nstcactus\baslesmasques\services\BasLesMasquesService;
use nstcactus\baslesmasques\variables\BasLesMasquesVariable;
use Craft;
use craft\base\Plugin as BasePlugin;
use craft\web\twig\variables\CraftVariable;
use yii\base\Event;
/**
* Class BasLesMasques
*
* @author nstCactus
* @package BasLesMasques
* @since 1.0.0
*
* @property BasLesMasquesService $service
* @property-read Settings $settings
* @method Settings getSettings()
*/
class Plugin extends BasePlugin
{
/**
* @inheritdoc
*/
public function init(): void
{
parent::init();
$this->set('service', BasLesMasquesService::class);
Event::on(
CraftVariable::class,
CraftVariable::EVENT_INIT,
static function (Event $event) {
/** @var CraftVariable $variable */
$variable = $event->sender;
$variable->set('basLesMasques', BasLesMasquesVariable::class);
}
);
Craft::info(
Craft::t(
'bas-les-masques',
'{name} plugin loaded',
['name' => $this->name]
),
__METHOD__
);
}
/**
* @return ?Settings
*/
protected function createSettingsModel(): ?Model
{
return new Settings();
}
}