1
|
|
|
<?php |
2
|
|
|
namespace NOSQL\Services\Base; |
3
|
|
|
|
4
|
|
|
use NOSQL\Services\Helpers\NOSQLApiHelper; |
5
|
|
|
use PSFS\base\dto\JsonResponse; |
6
|
|
|
use PSFS\base\types\AuthAdminController; |
7
|
|
|
use PSFS\base\types\helpers\ApiFormHelper; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Trait NOSQLManagetTrait |
11
|
|
|
* @package NOSQL\Services\base |
12
|
|
|
*/ |
13
|
|
|
trait NOSQLManagerTrait { |
14
|
|
|
/** |
15
|
|
|
* @label Returns form data for any nosql document |
16
|
|
|
* @POST |
17
|
|
|
* @visible false |
18
|
|
|
* @route /admin/api/form/{__DOMAIN__}/{__API__}/nosql |
19
|
|
|
* @return \PSFS\base\dto\JsonResponse(data=\PSFS\base\dto\Form) |
20
|
|
|
* @throws \Exception |
21
|
|
|
*/ |
22
|
|
|
public function getForm() |
23
|
|
|
{ |
24
|
|
|
$form = NOSQLApiHelper::parseForm($this->getModel()->getSchema()); |
|
|
|
|
25
|
|
|
$form->actions = ApiFormHelper::checkApiActions(get_called_class(), $this->getDomain(), $this->getApi()); |
|
|
|
|
26
|
|
|
|
27
|
|
|
return $this->_json(new JsonResponse($form->toArray(), TRUE), 200); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
protected function generateForm() { |
31
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @label {__API__} NOSQL Manager |
36
|
|
|
* @GET |
37
|
|
|
* @route /admin/{__DOMAIN__}/{__API__}/manager |
38
|
|
|
* @return string HTML |
39
|
|
|
*/ |
40
|
|
|
public function admin() { |
41
|
|
|
$domain = $this->getDomain(); |
42
|
|
|
$api = $this->getApi(); |
43
|
|
|
$data = array( |
44
|
|
|
"api" => $api, |
45
|
|
|
"domain" => $this->getDomain(), |
46
|
|
|
"listLabel" => self::API_LIST_NAME_FIELD, |
|
|
|
|
47
|
|
|
'modelId' => self::NOSQL_MODEL_PRIMARY_KEY, |
|
|
|
|
48
|
|
|
'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $domain . '-' . $api . '-nosql'), TRUE)), |
|
|
|
|
49
|
|
|
"url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($domain . '-' . 'api-' . $api . "-pk"), TRUE)), |
50
|
|
|
); |
51
|
|
|
return AuthAdminController::getInstance()->render('api.admin.html.twig', $data, [], ''); |
52
|
|
|
} |
53
|
|
|
} |