Passed
Push — develop ( aa4282...8b6a2b )
by Nikolay
05:16 queued 10s
created

LicensingController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 14
c 0
b 0
f 0
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A modifyAction() 0 21 2
A saveAction() 0 3 1
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, 6 2018
7
 *
8
 */
9
10
namespace MikoPBX\AdminCabinet\Controllers;
11
12
use MikoPBX\AdminCabinet\Forms\LicensingActivateCouponForm;
13
use MikoPBX\AdminCabinet\Forms\LicensingChangeLicenseKeyForm;
14
use MikoPBX\AdminCabinet\Forms\LicensingGetKeyForm;
15
use MikoPBX\Common\Models\PbxSettings;
16
use Phalcon\Text;
17
use SimpleXMLElement;
18
19
/**
20
 * @property \MikoPBX\Service\License license
21
 */
22
class LicensingController extends BaseController
23
{
24
    /**
25
     * License key, get new key, activate coupon form
26
     *
27
     */
28
    public function modifyAction(): void
29
    {
30
        if ($this->language === 'ru') {
31
            $this->view->modulesExampleImgPath = $this->url->get('assets/img/modules-example-ru.png');
32
        } else {
33
            $this->view->modulesExampleImgPath = $this->url->get('assets/img/modules-example-en.png');
34
        }
35
36
        // License key form
37
        $licKey                           = PbxSettings::getValueByKey('PBXLicense');
38
        $changeLicenseKeyForm             = new LicensingChangeLicenseKeyForm(null, ['licKey' => $licKey]);
39
        $this->view->changeLicenseKeyForm = $changeLicenseKeyForm;
40
41
        // Coupon form
42
        $activateCouponForm             = new LicensingActivateCouponForm();
43
        $this->view->activateCouponForm = $activateCouponForm;
44
45
        // Get new license key form
46
        $getKeyForm             = new LicensingGetKeyForm();
47
        $this->view->getKeyForm = $getKeyForm;
48
        $this->view->submitMode = null;
49
    }
50
51
    /**
52
     * After some changes on form we will refresh some session cache
53
     */
54
    public function saveAction()
55
    {
56
        $this->session->remove('PBXLicense');
57
    }
58
59
60
}