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
|
|
|
|
20
|
|
|
namespace MikoPBX\PbxCore; |
21
|
|
|
|
22
|
|
|
use MikoPBX\Common\Handlers\CriticalErrorsHandler; |
23
|
|
|
use MikoPBX\Common\Providers\RegistryProvider; |
24
|
|
|
use MikoPBX\PBXCoreREST\Config\RegisterDIServices; |
25
|
|
|
use Phalcon\Di\FactoryDefault; |
26
|
|
|
use Phalcon\Mvc\Micro; |
27
|
|
|
use Throwable; |
28
|
|
|
|
29
|
|
|
class RestAPI extends Micro |
30
|
|
|
{ |
31
|
|
|
public function main() |
32
|
|
|
{ |
33
|
|
|
// Create Dependency injector |
34
|
|
|
$di = new FactoryDefault(); |
35
|
|
|
|
36
|
|
|
// Auto-loader configuration |
37
|
|
|
require_once __DIR__ . '/../../src/Common/Config/ClassLoader.php'; |
38
|
|
|
|
39
|
|
|
//Load application services |
40
|
|
|
$application = new Micro(); |
41
|
|
|
$application->setDI($di); |
42
|
|
|
$di->setShared('application', $application); |
43
|
|
|
RegisterDIServices::init($di); |
44
|
|
|
|
45
|
|
|
// Start application |
46
|
|
|
try { |
47
|
|
|
$application->handle($_SERVER['REQUEST_URI']); |
48
|
|
|
} catch (Throwable $e) { |
49
|
|
|
CriticalErrorsHandler::handleException($e,'pbx-core-rest'); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
$restApi= new RestAPI(); |
54
|
|
|
$restApi->main(); |