1 | <?php |
||
2 | /** |
||
3 | * Connect plugin for Craft CMS 3.x |
||
4 | * |
||
5 | * Allows you to connect to external databases and perform db queries |
||
6 | * |
||
7 | * @link https://nystudio107.com/ |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
8 | * @copyright Copyright (c) 2018 nystudio107 |
||
0 ignored issues
–
show
|
|||
9 | */ |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | namespace nystudio107\connect; |
||
12 | |||
13 | use nystudio107\connect\models\Settings; |
||
14 | use nystudio107\connect\variables\ConnectVariable; |
||
15 | |||
16 | use Craft; |
||
17 | use craft\base\Plugin; |
||
18 | use craft\web\twig\variables\CraftVariable; |
||
19 | |||
20 | use yii\base\Event; |
||
21 | |||
22 | /** |
||
23 | * Class Connect |
||
24 | * |
||
25 | * @author nystudio107 |
||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||
26 | * @package Connect |
||
0 ignored issues
–
show
|
|||
27 | * @since 1.0.0 |
||
0 ignored issues
–
show
|
|||
28 | */ |
||
0 ignored issues
–
show
|
|||
29 | class Connect extends Plugin |
||
30 | { |
||
31 | // Static Properties |
||
32 | // ========================================================================= |
||
33 | |||
34 | /** |
||
0 ignored issues
–
show
|
|||
35 | * @var Connect |
||
36 | */ |
||
37 | public static $plugin; |
||
38 | |||
39 | // Public Properties |
||
40 | // ========================================================================= |
||
41 | |||
42 | /** |
||
0 ignored issues
–
show
|
|||
43 | * @var string |
||
44 | */ |
||
45 | public $schemaVersion = '1.0.0'; |
||
46 | |||
47 | // Public Methods |
||
48 | // ========================================================================= |
||
49 | |||
50 | /** |
||
0 ignored issues
–
show
|
|||
51 | * @inheritdoc |
||
52 | */ |
||
0 ignored issues
–
show
|
|||
53 | public function init() |
||
54 | { |
||
55 | parent::init(); |
||
56 | self::$plugin = $this; |
||
57 | |||
58 | Event::on( |
||
59 | CraftVariable::class, |
||
60 | CraftVariable::EVENT_INIT, |
||
61 | function (Event $event) { |
||
62 | /** @var CraftVariable $variable */ |
||
0 ignored issues
–
show
|
|||
63 | $variable = $event->sender; |
||
64 | $variable->set('connect', ConnectVariable::class); |
||
65 | } |
||
66 | ); |
||
67 | |||
68 | Craft::info( |
||
69 | Craft::t( |
||
70 | 'connect', |
||
71 | '{name} plugin loaded', |
||
72 | ['name' => $this->name] |
||
73 | ), |
||
74 | __METHOD__ |
||
75 | ); |
||
76 | } |
||
77 | |||
78 | // Protected Methods |
||
79 | // ========================================================================= |
||
80 | |||
81 | /** |
||
0 ignored issues
–
show
|
|||
82 | * @inheritdoc |
||
83 | */ |
||
0 ignored issues
–
show
|
|||
84 | protected function createSettingsModel() |
||
85 | { |
||
86 | return new Settings(); |
||
87 | } |
||
88 | } |
||
89 |