@@ 55-69 (lines=15) @@ | ||
52 | * @param string $model_name |
|
53 | * @return WP_REST_Response|\WP_Error |
|
54 | */ |
|
55 | public static function handleRequestInsert(WP_REST_Request $request, $version, $model_name) |
|
56 | { |
|
57 | $controller = new Write(); |
|
58 | try { |
|
59 | $controller->setRequestedVersion($version); |
|
60 | return $controller->sendResponse( |
|
61 | $controller->insert( |
|
62 | $controller->getModelVersionInfo()->loadModel($model_name), |
|
63 | $request |
|
64 | ) |
|
65 | ); |
|
66 | } catch (Exception $e) { |
|
67 | return $controller->sendResponse($e); |
|
68 | } |
|
69 | } |
|
70 | ||
71 | ||
72 | /** |
|
@@ 80-94 (lines=15) @@ | ||
77 | * @param string $model_name |
|
78 | * @return WP_REST_Response|\WP_Error |
|
79 | */ |
|
80 | public static function handleRequestUpdate(WP_REST_Request $request, $version, $model_name) |
|
81 | { |
|
82 | $controller = new Write(); |
|
83 | try { |
|
84 | $controller->setRequestedVersion($version); |
|
85 | return $controller->sendResponse( |
|
86 | $controller->update( |
|
87 | $controller->getModelVersionInfo()->loadModel($model_name), |
|
88 | $request |
|
89 | ) |
|
90 | ); |
|
91 | } catch (Exception $e) { |
|
92 | return $controller->sendResponse($e); |
|
93 | } |
|
94 | } |
|
95 | ||
96 | ||
97 | /** |
|
@@ 105-119 (lines=15) @@ | ||
102 | * @param string $model_name |
|
103 | * @return WP_REST_Response|\WP_Error |
|
104 | */ |
|
105 | public static function handleRequestDelete(WP_REST_Request $request, $version, $model_name) |
|
106 | { |
|
107 | $controller = new Write(); |
|
108 | try { |
|
109 | $controller->setRequestedVersion($version); |
|
110 | return $controller->sendResponse( |
|
111 | $controller->delete( |
|
112 | $controller->getModelVersionInfo()->loadModel($model_name), |
|
113 | $request |
|
114 | ) |
|
115 | ); |
|
116 | } catch (Exception $e) { |
|
117 | return $controller->sendResponse($e); |
|
118 | } |
|
119 | } |
|
120 | ||
121 | ||
122 | /** |
|
@@ 414-428 (lines=15) @@ | ||
411 | * @param WP_REST_Request $request |
|
412 | * @return WP_REST_Response |
|
413 | */ |
|
414 | public static function handleRequestRemoveRelation(WP_REST_Request $request, $version, $model_name, $related_model_name) |
|
415 | { |
|
416 | $controller = new Write(); |
|
417 | try { |
|
418 | $controller->setRequestedVersion($version); |
|
419 | return $controller->sendResponse( |
|
420 | $controller->insert( |
|
421 | $controller->getModelVersionInfo()->loadModel($model_name), |
|
422 | $request |
|
423 | ) |
|
424 | ); |
|
425 | } catch (Exception $e) { |
|
426 | return $controller->sendResponse($e); |
|
427 | } |
|
428 | } |
|
429 | ||
430 | /** |
|
431 | * Adds a relation between the two model specified model objects. |