FOSSology  4.7.1
Open Source License Compliance by Open Source Software
Fossology\UI\Api\Controllers\RestController Class Reference

Base controller for REST calls. More...

Inheritance diagram for Fossology\UI\Api\Controllers\RestController:
Inheritance graph
Collaboration diagram for Fossology\UI\Api\Controllers\RestController:
Collaboration graph

Public Member Functions

 __construct ($container)
 
 isJsonRequest ($request)
 

Protected Member Functions

 getParsedBody (ServerRequestInterface $request)
 Parse request body as JSON and return associative PHP array. More...
 
 throwNotAdminException ()
 
 uploadAccessible ($id)
 
 uploadEditable ($id)
 
 isItemExists (int $uploadId, int $itemId)
 

Protected Attributes

 $container
 
 $restHelper
 
 $dbHelper
 

Detailed Description

Base controller for REST calls.

Definition at line 29 of file RestController.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ 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$requestRequest 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
int$uploadId
int$itemId
Returns
void
Exceptions
HttpNotFoundException

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
HttpForbiddenException

Definition at line 85 of file RestController.php.

◆ uploadAccessible()

Fossology\UI\Api\Controllers\RestController::uploadAccessible (   $id)
protected

Check if upload is accessible

Parameters
integer$idUpload ID
Exceptions
HttpNotFoundExceptionUpload not found
HttpForbiddenExceptionUpload 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
integer$idUpload ID
Exceptions
HttpNotFoundExceptionUpload not found
HttpForbiddenExceptionUpload not editable by current group

Definition at line 121 of file RestController.php.

Member Data Documentation

◆ $container

ContainerInterface Fossology\UI\Api\Controllers\RestController::$container
protected

Slim container

Definition at line 35 of file RestController.php.

◆ $dbHelper

DbHelper Fossology\UI\Api\Controllers\RestController::$dbHelper
protected

DB helper object in use

Definition at line 47 of file RestController.php.

◆ $restHelper

RestHelper Fossology\UI\Api\Controllers\RestController::$restHelper
protected

Rest helper object in use

Definition at line 41 of file RestController.php.


The documentation for this class was generated from the following file: