ManageOrganizationTypeProjectConfig   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 33
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 10 1
A delete() 0 9 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\events;
10
11
use Craft;
12
use craft\events\ConfigEvent;
13
use flipbox\organizations\records\OrganizationType;
14
use yii\db\AfterSaveEvent;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 3.0.0
19
 */
20
class ManageOrganizationTypeProjectConfig
21
{
22
    /**
23
     * @param AfterSaveEvent $event
24
     * @throws \yii\base\ErrorException
25
     * @throws \yii\base\Exception
26
     * @throws \yii\base\NotSupportedException
27
     * @throws \yii\web\ServerErrorHttpException
28
     */
29
    public static function save(AfterSaveEvent $event)
30
    {
31
        /** @var OrganizationType $record */
32
        $record = $event->sender;
33
34
        Craft::$app->getProjectConfig()->set(
35
            'plugins.organizations.organizationTypes.' . $record->uid,
36
            $record->toProjectConfig()
37
        );
38
    }
39
40
    /**
41
     * @param ConfigEvent $event
42
     */
43
    public static function delete(ConfigEvent $event)
44
    {
45
        /** @var OrganizationType $record */
46
        $record = $event->sender;
47
48
        Craft::$app->getProjectConfig()->remove(
49
            'plugins.organizations.organizationTypes.' . $record->uid
50
        );
51
    }
52
}
53