Ivan - Backend - Add /system/get-settings path[skip ci]
This commit is contained in:
parent
7dc7e14168
commit
4b7ece614f
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
require_once 'system/init-settings.php';
|
||||
require_once 'system/get-settings.php';
|
||||
|
||||
$systemControllerGroup = new ControllerGroup();
|
||||
$systemControllerGroup->setGroupPath('/system');
|
||||
|
||||
$systemControllerGroup->addController(new InitSettingsController);
|
||||
$systemControllerGroup->addController(new GetSettingsController);
|
||||
|
||||
$systemControllerGroup->finalize();
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
class GetSettingsController extends Controller {
|
||||
const PATH = '/get-settings';
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => 'any',
|
||||
'requestData' => []
|
||||
];
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
Response::respondSuccess([
|
||||
'language' => Setting::getSetting('language')->getValue(),
|
||||
'reCaptchaKey' => Setting::getSetting('recaptcha-public')->getValue(),
|
||||
'departments' => Department::getDepartmentNames()
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -25,6 +25,8 @@ class InitSettingsController extends Controller {
|
|||
private function storeGlobalSettings() {
|
||||
$this->storeSettings([
|
||||
'language' => 'en',
|
||||
'recaptcha-public' => '6LfM5CYTAAAAAGLz6ctpf-hchX2_l0Ge-Bn-n8wS',
|
||||
'recaptcha-private' => '6LfM5CYTAAAAAP3dfBJfC49X2qVm0tH9IZ-VZjzw',
|
||||
'no-reply-email' => 'noreply@opensupports.com',
|
||||
'smtp-host' => 'localhost',
|
||||
'smtp-port' => 7070,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
|
||||
class Department extends DataStore {
|
||||
const TABLE = 'department';
|
||||
|
@ -9,4 +10,15 @@ class Department extends DataStore {
|
|||
'sharedTicketList'
|
||||
];
|
||||
}
|
||||
|
||||
public static function getDepartmentNames() {
|
||||
$departmentsQuantity = RedBean::count(Department::TABLE);
|
||||
$departmentsNameList = [];
|
||||
|
||||
for ($departmentIndex = 1; $departmentIndex <= $departmentsQuantity; ++$departmentIndex) {
|
||||
$departmentsNameList[] = Department::getDataStore($departmentIndex)->name;
|
||||
}
|
||||
|
||||
return $departmentsNameList;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue