Passed
Push — develop ( d91dd3...b816f7 )
by Nikolay
05:31
created

PbxExtensionModules::afterDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (C) MIKO LLC - All Rights Reserved
4
 * Unauthorized copying of this file, via any medium is strictly prohibited
5
 * Proprietary and confidential
6
 * Written by Nikolay Beketov, 5 2018
7
 *
8
 */
9
10
namespace MikoPBX\Common\Models;
11
12
use MikoPBX\Common\Providers\PBXConfModulesProvider;
13
use Phalcon\Validation;
14
use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator;
15
16
/**
17
 * @method static mixed findFirstByUniqid(array|string|int $parameters = null)
18
 */
19
class PbxExtensionModules extends ModelsBase
20
{
21
    /**
22
     * @Primary
23
     * @Identity
24
     * @Column(type="integer", nullable=false)
25
     */
26
    public $id;
27
28
    /**
29
     * @Column(type="string", nullable=true)
30
     */
31
    public $uniqid;
32
33
    /**
34
     * @Column(type="string", nullable=true)
35
     */
36
    public $name;
37
38
    /**
39
     * @Column(type="string", nullable=true)
40
     */
41
    public $version;
42
43
    /**
44
     * @Column(type="string", nullable=true)
45
     */
46
    public $developer;
47
48
    /**
49
     * @Column(type="string", nullable=true, column="supportemail")
50
     */
51
    public $support_email;
52
53
    /**
54
     * @Column(type="string", nullable=true)
55
     */
56
    public $path;
57
58
    /**
59
     * @Column(type="string", nullable=true)
60
     */
61
    public $description;
62
63
    /**
64
     * @Column(type="integer", nullable=true)
65
     */
66
    public $disabled;
67
68
69
    public function initialize(): void
70
    {
71
        $this->setSource('m_PbxExtensionModules');
72
        parent::initialize();
73
    }
74
75
    public function validation(): bool
76
    {
77
        $validation = new Validation();
78
        $validation->add(
79
            'uniqid',
80
            new UniquenessValidator(
81
                [
82
                    'message' => $this->t('mo_ThisUniqidMustBeUniqueForPbxExtensionModulesModels'),
83
                ]
84
            )
85
        );
86
87
        return $this->validate($validation);
88
    }
89
90
    /**
91
     * After change PBX modules need recreate shared services
92
     */
93
    public function afterSave(): void
94
    {
95
        parent::afterSave();
96
        $this->di->remove('pbxConfModules');
0 ignored issues
show
Bug Best Practice introduced by
The property di does not exist on MikoPBX\Common\Models\PbxExtensionModules. Since you implemented __get, consider adding a @property annotation.
Loading history...
97
        $this->di->register(new PBXConfModulesProvider());
98
    }
99
100
    /**
101
     * After change PBX modules need recreate shared services
102
     */
103
    public function afterDelete(): void
104
    {
105
        parent::afterDelete();
106
        $this->di->remove('pbxConfModules');
0 ignored issues
show
Bug Best Practice introduced by
The property di does not exist on MikoPBX\Common\Models\PbxExtensionModules. Since you implemented __get, consider adding a @property annotation.
Loading history...
107
        $this->di->register(new PBXConfModulesProvider());
108
    }
109
}
110
111