Base controller for REST calls.
More...
Base controller for REST calls.
Definition at line 29 of file RestController.php.
◆ __construct()
| Fossology\UI\Api\Controllers\RestController::__construct |
( |
|
$container | ) |
|
◆ getParsedBody()
| Fossology\UI\Api\Controllers\RestController::getParsedBody |
( |
ServerRequestInterface |
$request | ) |
|
|
protected |
Parse request body as JSON and return associative PHP array.
If request is of type application/json, read the body content and parse with json_decode(). Otherwise, use slim's getParsedBody().
- Parameters
-
| ServerRequestInterface | $request | Request to parse |
- Returns
- array|null Parsed JSON, or null on error
Definition at line 69 of file RestController.php.
◆ isItemExists()
| Fossology\UI\Api\Controllers\RestController::isItemExists |
( |
int |
$uploadId, |
|
|
int |
$itemId |
|
) |
| |
|
protected |
Check if an upload tree item belongs to the requested upload
- Parameters
-
- Returns
- void
- Exceptions
-
Definition at line 139 of file RestController.php.
◆ isJsonRequest()
| Fossology\UI\Api\Controllers\RestController::isJsonRequest |
( |
|
$request | ) |
|
Check if request contains header "Content-Type: application/json
- Parameters
-
| ServerRequestInterface | $request | |
- Returns
- bool
Definition at line 154 of file RestController.php.
◆ throwNotAdminException()
| Fossology\UI\Api\Controllers\RestController::throwNotAdminException |
( |
| ) |
|
|
protected |
Throw an HttpForbiddenException if the user is not admin.
- Exceptions
-
Definition at line 85 of file RestController.php.
◆ uploadAccessible()
| Fossology\UI\Api\Controllers\RestController::uploadAccessible |
( |
|
$id | ) |
|
|
protected |
Check if upload is accessible
- Parameters
-
- Exceptions
-
| HttpNotFoundException | Upload not found |
| HttpForbiddenException | Upload not accessible |
Definition at line 99 of file RestController.php.
◆ uploadEditable()
| Fossology\UI\Api\Controllers\RestController::uploadEditable |
( |
|
$id | ) |
|
|
protected |
Check if upload is accessible and editable (requires write permission).
A user with only read access to an upload must not be allowed to mutate its findings via the REST API. This mirrors the guard already applied in the legacy UI (e.g. ui-clearing-view.php, ajax-acknowledgement-conf.php).
- Parameters
-
- Exceptions
-
| HttpNotFoundException | Upload not found |
| HttpForbiddenException | Upload not editable by current group |
Definition at line 121 of file RestController.php.
◆ $container
| ContainerInterface Fossology\UI\Api\Controllers\RestController::$container |
|
protected |
◆ $dbHelper
| DbHelper Fossology\UI\Api\Controllers\RestController::$dbHelper |
|
protected |
◆ $restHelper
| RestHelper Fossology\UI\Api\Controllers\RestController::$restHelper |
|
protected |
The documentation for this class was generated from the following file: