Completed
Push — master ( 9a35ef...065a6e )
by Nate
06:08 queued 04:09
created

Cp   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 44
ccs 0
cts 23
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 14 1
A beforeAction() 0 8 2
A getSettings() 0 4 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/organization/license
6
 * @link       https://www.flipboxfactory.com/software/organization/
7
 */
8
9
namespace flipbox\organizations\cp;
10
11
use Craft;
12
use craft\events\RegisterTemplateRootsEvent;
13
use craft\web\View;
14
use flipbox\organizations\Organizations;
15
use yii\base\Event;
16
use yii\base\Module as BaseModule;
17
use yii\web\NotFoundHttpException;
18
19
/**
20
 * @author Flipbox Factory <[email protected]>
21
 * @since 1.0.0
22
 *
23
 * @property Organizations $module
24
 */
25
class Cp extends BaseModule
26
{
27
    /**
28
     * @inheritdoc
29
     */
30
    public function init()
31
    {
32
        parent::init();
33
34
        // Base template directory
35
        Event::on(
36
            View::class,
37
            View::EVENT_REGISTER_CP_TEMPLATE_ROOTS,
38
            function (RegisterTemplateRootsEvent $e) {
39
                $e->roots['nested-element-index'] = Craft::$app->getPath()->getVendorPath() .
40
                    '/flipboxfactory/craft-elements-nested-index/src/templates';
41
            }
42
        );
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function beforeAction($action)
49
    {
50
        if (!Craft::$app->request->getIsCpRequest()) {
51
            throw new NotFoundHttpException();
52
        }
53
54
        return parent::beforeAction($action);
55
    }
56
57
    /*******************************************
58
     * SERVICES
59
     *******************************************/
60
61
    /**
62
     * @return services\Settings
63
     */
64
    public function getSettings()
65
    {
66
        return $this->get('settings');
67
    }
68
}
69