Passed
Branch develop (c87c46)
by Nikolay
05:17
created

Application::main()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 20
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/*
3
 * MikoPBX - free phone system for small business
4
 * Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with this program.
17
 * If not, see <https://www.gnu.org/licenses/>.
18
 */
19
namespace MikoPBX\AdminCabinet;
20
21
use MikoPBX\Common\Config\RegisterDIServices as RegisterCommonDIServices;
22
use MikoPBX\Common\Handlers\CriticalErrorsHandler;
23
use MikoPBX\Modules\PbxExtensionUtils;
24
use Phalcon\Mvc\Application as BaseApplication;
25
26
class Application extends BaseApplication
27
{
28
    /**
29
     * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
30
     */
31
    protected function registerServices()
32
    {
33
34
        $di = new \Phalcon\Di\FactoryDefault();
35
36
        /**
37
         * Auto-loader configuration
38
         */
39
        require_once __DIR__ . '/../../src/Common/Config/ClassLoader.php';
40
41
        RegisterCommonDIServices::init($di);
42
43
        $this->setDI($di);
44
    }
45
46
    public function main()
47
    {
48
        $this->registerServices();
49
50
        // Register the default modules
51
        $this->registerModules([
52
            'admin-cabinet' => [
53
                "className" => "MikoPBX\AdminCabinet\Module",
54
                "path"      => __DIR__ . '/../../src/AdminCabinet/Module.php',
55
            ],
56
        ]);
57
        $this->setDefaultModule('admin-cabinet');
58
59
        // Register additional app modules from external enabled modules
60
        PbxExtensionUtils::registerEnabledModulesInApp($this);
61
62
        try {
63
            echo $this->handle($_SERVER['REQUEST_URI'])->getContent();
64
        } catch (\Throwable $e) {
65
            CriticalErrorsHandler::handleException($e);
66
        }
67
    }
68
}
69
70
$application = new Application();
71
$application->main();
72