@@ 76-104 (lines=29) @@ | ||
73 | * @throws InvalidDataTypeException |
|
74 | * @throws InvalidInterfaceException |
|
75 | */ |
|
76 | public static function handleRequestGetAll(WP_REST_Request $request, $version, $model_name) |
|
77 | { |
|
78 | $controller = LoaderFactory::getLoader()->getNew('EventEspresso\core\libraries\rest_api\controllers\model\Read'); |
|
79 | try { |
|
80 | $controller->setRequestedVersion($version); |
|
81 | if (! $controller->getModelVersionInfo()->isModelNameInThisVersion($model_name)) { |
|
82 | return $controller->sendResponse( |
|
83 | new WP_Error( |
|
84 | 'endpoint_parsing_error', |
|
85 | sprintf( |
|
86 | __( |
|
87 | 'There is no model for endpoint %s. Please contact event espresso support', |
|
88 | 'event_espresso' |
|
89 | ), |
|
90 | $model_name |
|
91 | ) |
|
92 | ) |
|
93 | ); |
|
94 | } |
|
95 | return $controller->sendResponse( |
|
96 | $controller->getEntitiesFromModel( |
|
97 | $controller->getModelVersionInfo()->loadModel($model_name), |
|
98 | $request |
|
99 | ) |
|
100 | ); |
|
101 | } catch (Exception $e) { |
|
102 | return $controller->sendResponse($e); |
|
103 | } |
|
104 | } |
|
105 | ||
106 | ||
107 | /** |
|
@@ 256-284 (lines=29) @@ | ||
253 | * @throws InvalidInterfaceException |
|
254 | * @throws InvalidArgumentException |
|
255 | */ |
|
256 | public static function handleRequestGetOne(WP_REST_Request $request, $version, $model_name) |
|
257 | { |
|
258 | $controller = LoaderFactory::getLoader()->getNew('EventEspresso\core\libraries\rest_api\controllers\model\Read'); |
|
259 | try { |
|
260 | $controller->setRequestedVersion($version); |
|
261 | if (! $controller->getModelVersionInfo()->isModelNameInThisVersion($model_name)) { |
|
262 | return $controller->sendResponse( |
|
263 | new WP_Error( |
|
264 | 'endpoint_parsing_error', |
|
265 | sprintf( |
|
266 | __( |
|
267 | 'There is no model for endpoint %s. Please contact event espresso support', |
|
268 | 'event_espresso' |
|
269 | ), |
|
270 | $model_name |
|
271 | ) |
|
272 | ) |
|
273 | ); |
|
274 | } |
|
275 | return $controller->sendResponse( |
|
276 | $controller->getEntityFromModel( |
|
277 | $controller->getModelVersionInfo()->loadModel($model_name), |
|
278 | $request |
|
279 | ) |
|
280 | ); |
|
281 | } catch (Exception $e) { |
|
282 | return $controller->sendResponse($e); |
|
283 | } |
|
284 | } |
|
285 | ||
286 | ||
287 | /** |