FrontMatter::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 13
ccs 7
cts 7
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link https://www.github.com/tinydots/craft-front-matter
4
 * @copyright Copyright (c) Mike Pepper
5
 * @license MIT
6
 */
7
8
namespace tinydots\frontmatter;
9
10
use tinydots\frontmatter\services\FrontMatterService;
11
use tinydots\frontmatter\variables\FrontMatterVariable;
12
use craft\base\Plugin;
13
use craft\web\twig\variables\CraftVariable;
14
use yii\base\Event;
15
16
/**
17
 * Class FrontMatter
18
 *
19
 * @property FrontMatterService $frontMatter
20
 * @author Mike Pepper <[email protected]>
21
 * @since 1.0.0
22
 */
23
class FrontMatter extends Plugin
24
{
25
    /** @var FrontMatter */
26
    public static $plugin;
27
28 3
    public function init()
29
    {
30 3
        parent::init();
31
32 3
        self::$plugin = $this;
33
34 3
        $this->setComponents([
35 3
            'frontMatter' => FrontMatterService::class,
36
        ]);
37
38
        Event::on(CraftVariable::class, CraftVariable::EVENT_INIT, function(Event $event) {
39 1
            $variable = $event->sender;
40 1
            $variable->set('frontMatter', FrontMatterVariable::class);
41 3
        });
42
    }
43
}