forked from YetiForceCompany/YetiForceCRM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webservice.php
35 lines (35 loc) · 1.15 KB
/
webservice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/**
* @copyright YetiForce Sp. z o.o
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com)
*/
require_once 'include/main/WebUI.php';
\App\Process::$requestMode = 'API';
\App\Log::beginProfile($_SERVER['REQUEST_URI'], 'WebServiceAPI');
try {
if (!\in_array('webservice', \App\Config::api('enabledServices'))) {
throw new \App\Exceptions\NoPermittedToApi('Webservice - Service is not active', 403);
}
$controller = Api\Controller::getInstance();
$process = $controller->preProcess();
if ($process) {
$controller->process();
}
$controller->postProcess();
} catch (\Api\Core\Exception $e) {
\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
$e->handleError();
} catch (\App\Exceptions\NoPermittedToApi $e) {
\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
echo json_encode([
'status' => 0,
'error' => [
'message' => $e->getMessage(),
],
]);
} catch (\Throwable $e) {
\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
$ex = new \Api\Core\Exception($e->getMessage(), $e->getCode(), $e);
$ex->handleError();
}
\App\Log::endProfile($_SERVER['REQUEST_URI'], 'WebServiceAPI');