Completed
Push — develop ( 94466e...7ae3b4 )
by Nate
04:02
created

Restful::getLogFileName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/restful/license
6
 * @link       https://www.flipboxfactory.com/software/restful/
7
 */
8
9
namespace flipbox\craft\restful;
10
11
use Craft;
12
use craft\base\Plugin;
13
use flipbox\craft\rbac\DbManager;
14
use flipbox\craft\restful\models\Settings as SettingsModel;
15
use flipbox\ember\modules\LoggerTrait;
16
17
/**
18
 * @author Flipbox Factory <[email protected]>
19
 * @since 1.0.0
20
 *
21
 * @method SettingsModel getSettings()
22
 *
23
 * @property DbManager $authManager
24
 */
25
class Restful extends Plugin
26
{
27
    use LoggerTrait;
28
29
    /**
30
     * The transformer scope
31
     */
32
    const FLUX_SCOPE = 'rest';
33
34
    /**
35
     * @inheritdoc
36
     */
37
    public function init()
38
    {
39
        parent::init();
40
41
        // Components
42
        $this->setComponents([
43
            'authManage' => [
44
                "class" => DbManager::class,
45
                "itemTable" => "{{%restful_rbac_item}}",
46
                "itemChildTable" => "{{%restful_rbac_item_child}}",
47
                "assignmentTable" => "{{%restful_rbac_assignment}}",
48
                "ruleTable" => "{{%restful_rbac_rule}}"
49
            ]
50
        ]);
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    protected static function getLogFileName(): string
57
    {
58
        return 'restful';
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64
    public function createSettingsModel()
65
    {
66
        return new SettingsModel();
67
    }
68
69
    /**
70
     * Ensure our dependencies are installed
71
     *
72
     * @return bool
73
     * @throws \Throwable
74
     * @throws \craft\errors\InvalidPluginException
75
     */
76
    public function beforeInstall(): bool
77
    {
78
        if (!Craft::$app->getPlugins()->getPlugin('flux')) {
79
            Craft::$app->getPlugins()->installPlugin('flux');
80
        }
81
82
        return parent::beforeInstall();
83
    }
84
85
    /*******************************************
86
     * SERVICES
87
     *******************************************/
88
89
    /**
90
     * @noinspection PhpDocMissingThrowsInspection
91
     * @return DbManager
92
     */
93
    public function getAuthManager(): DbManager
94
    {
95
        /** @noinspection PhpUnhandledExceptionInspection */
96
        /** @noinspection PhpIncompatibleReturnTypeInspection */
97
        return $this->get('authManager');
98
    }
99
}
100