Passed
Branch develop (078eb3)
by Andrew
05:54 queued 03:15
created

Connect::createSettingsModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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/
8
 * @copyright Copyright (c) 2018 nystudio107
9
 */
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
26
 * @package   Connect
27
 * @since     1.0.0
28
 */
29
class Connect extends Plugin
30
{
31
    // Static Properties
32
    // =========================================================================
33
34
    /**
35
     * @var Connect
36
     */
37
    public static $plugin;
38
39
    // Public Properties
40
    // =========================================================================
41
42
    /**
43
     * @var string
44
     */
45
    public $schemaVersion = '1.0.0';
46
47
    // Public Methods
48
    // =========================================================================
49
50
    /**
51
     * @inheritdoc
52
     */
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 */
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
    /**
82
     * @inheritdoc
83
     */
84
    protected function createSettingsModel()
85
    {
86
        return new Settings();
87
    }
88
}
89