forked from YetiForceCompany/YetiForceCRM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webservice.php
39 lines (38 loc) · 1.27 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
36
37
38
39
<?php
/**
* Web service init file.
*
* @package API
*
* @copyright YetiForce S.A.
* @license YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
* @author Mariusz Krzaczkowski <[email protected]>
*/
chdir(__DIR__);
require_once __DIR__ . '/include/main/WebUI.php';
require_once __DIR__ . '/include/RequirementsValidation.php';
\App\Process::$requestMode = 'API';
\App\Log::beginProfile(\App\Request::getRequestMethod() . '::' . $_SERVER['REQUEST_URI'], 'WebServiceAPI');
try {
if (!\in_array('webservice', \App\Config::api('enabledServices'))) {
throw new \App\Exceptions\NoPermittedToApi('Webservice - Service is not active', 503);
}
$controller = Api\Controller::getInstance();
try {
$process = $controller->preProcess();
if ($process) {
$controller->process();
}
$controller->postProcess();
} catch (\Throwable $e) {
\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
$controller->handleError($e);
}
} catch (\Throwable $e) {
\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
if (!headers_sent()) {
$ex = new \Api\Core\Exception($e->getMessage(), $e->getCode(), $e);
$ex->showError();
}
}
\App\Log::endProfile(\App\Request::getRequestMethod() . '::' . $_SERVER['REQUEST_URI'], 'WebServiceAPI');