RouterController
extends BaseApiController
in package
Table of Contents
- $errorLogName : string
- $warningLogName : string
- $apiVersionManager : ApiVersionManager
- This service manages the api versions
- $ensureApiVersions : array<string|int, mixed>
- Array of api versions for which, the controller that extends this Base, is available
- $jobsLogName : string
- The name of the log in which we are going to log actions performed by jobs
- __construct() : mixed
- Constructor, it ensures that the API version is valid for this element (i.e. the apiVersion should be minimum the one in which the functionalities was added)
- destroy() : RouterResource|JsonResponse
- Remove the specified resource from storage.
- generic401JsonError() : JsonResponse
- This function can be used anywhere in the code if you need to return a standard 401 unauth response
- generic403JsonError() : JsonResponse
- This function can be used anywhere in the code if you need to return a standard 403 unauth response
- generic404JsonError() : JsonResponse
- This function can be used anywhere in the code if you need to return a standard 404 unauth response
- generic500JsonError() : JsonResponse
- This function can be used anywhere in code if there is an application error
- history() : ActivityResourceCollection|JsonResponse
- index() : RouterResourceCollection|JsonResponse
- Display a listing of the resource.
- jsonResponse() : JsonResponse
- logEntry() : Activity
- logEntryWithoutModel() : Activity
- logError() : Activity
- logWarning() : Activity
- show() : RouterResource|JsonResponse
- Display the specified resource.
- store() : RouterResource|JsonResponse
- Store a newly created resource in storage.
- update() : RouterResource|JsonResponse
- Update the specified resource in storage.
- validationJsonError() : JsonResponse
- Returns a 422 error
- can() : mixed
- This function will check if the user can, given the policy for the $model, do the specified $action In case it will satisfy the requirements the $callback will be used to build a response, otherwise a json with the system wide defined response will be used as a return value.
- ensureApiVersions() : void
- This method will just save the apiVersions that have to checked.
- log() : array<string|int, Activity>
- assertDependency() : void
- This function will aseert that the resource <-> subresource relation
- jsonError() : JsonResponse
Properties
$errorLogName
public
static string
$errorLogName
= "error"
$warningLogName
public
static string
$warningLogName
= "warning"
$apiVersionManager
This service manages the api versions
protected
ApiVersionManager
$apiVersionManager
$ensureApiVersions
Array of api versions for which, the controller that extends this Base, is available
protected
array<string|int, mixed>
$ensureApiVersions
$jobsLogName
The name of the log in which we are going to log actions performed by jobs
protected
string
$jobsLogName
= "jobs"
Methods
__construct()
Constructor, it ensures that the API version is valid for this element (i.e. the apiVersion should be minimum the one in which the functionalities was added)
public
__construct(ApiVersionManager $apiVersionManager) : mixed
Parameters
- $apiVersionManager : ApiVersionManager
Return values
mixed —destroy()
Remove the specified resource from storage.
public
destroy(Request $request, Project $project, Router $router) : RouterResource|JsonResponse
Parameters
Return values
RouterResource|JsonResponse —generic401JsonError()
This function can be used anywhere in the code if you need to return a standard 401 unauth response
public
static generic401JsonError() : JsonResponse
Return values
JsonResponse —generic403JsonError()
This function can be used anywhere in the code if you need to return a standard 403 unauth response
public
static generic403JsonError() : JsonResponse
Return values
JsonResponse —generic404JsonError()
This function can be used anywhere in the code if you need to return a standard 404 unauth response
public
static generic404JsonError() : JsonResponse
Return values
JsonResponse —generic500JsonError()
This function can be used anywhere in code if there is an application error
public
static generic500JsonError(array<string|int, mixed> $errors) : JsonResponse
Parameters
- $errors : array<string|int, mixed>
Return values
JsonResponse —history()
public
history(Request $request, Project $project, Router $router) : ActivityResourceCollection|JsonResponse
Parameters
Return values
ActivityResourceCollection|JsonResponse —index()
Display a listing of the resource.
public
index(Request $request, Project $project) : RouterResourceCollection|JsonResponse
Parameters
- $request : Request
- $project : Project
Return values
RouterResourceCollection|JsonResponse —jsonResponse()
public
static jsonResponse(array<string|int, mixed> $data) : JsonResponse
Parameters
- $data : array<string|int, mixed>
Return values
JsonResponse —logEntry()
public
static logEntry(Model $model, array<string|int, mixed> $properties, string $description, string $event, string $logName) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
- $logName : string
Return values
Activity —logEntryWithoutModel()
public
static logEntryWithoutModel(array<string|int, mixed> $properties, string $description, string $event, string $logName) : Activity
Parameters
- $properties : array<string|int, mixed>
- $description : string
- $event : string
- $logName : string
Return values
Activity —logError()
public
static logError(Model $model, array<string|int, mixed> $properties, string $description, string $event) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
Return values
Activity —logWarning()
public
static logWarning(Model $model, array<string|int, mixed> $properties, string $description, string $event) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
Return values
Activity —show()
Display the specified resource.
public
show(Request $request, Project $project, Router $router) : RouterResource|JsonResponse
Parameters
Return values
RouterResource|JsonResponse —store()
Store a newly created resource in storage.
public
store(Request $request, Project $project) : RouterResource|JsonResponse
Parameters
- $request : Request
- $project : Project
Return values
RouterResource|JsonResponse —update()
Update the specified resource in storage.
public
update(Request $request, Project $project, Router $router) : RouterResource|JsonResponse
Parameters
Return values
RouterResource|JsonResponse —validationJsonError()
Returns a 422 error
public
static validationJsonError(array<string|int, mixed> $data, string $errorKey, string $message) : JsonResponse
Parameters
- $data : array<string|int, mixed>
- $errorKey : string
- $message : string
Return values
JsonResponse —can()
This function will check if the user can, given the policy for the $model, do the specified $action In case it will satisfy the requirements the $callback will be used to build a response, otherwise a json with the system wide defined response will be used as a return value.
protected
can(Request $request, string $action, string|Model $model, $callback[, bool $forceYes = false ]) : mixed
This function will also check if the current apiVersion is one of those for which the controller that extends this Base is available.
Parameters
- $request : Request
- $action : string
- $model : string|Model
- $callback :
- $forceYes : bool = false
-
If this parameter is true this function will not check the policy
Return values
mixed —ensureApiVersions()
This method will just save the apiVersions that have to checked.
protected
ensureApiVersions(array<string|int, mixed> $versions) : void
The real check will be done in the "can" function
Parameters
- $versions : array<string|int, mixed>
Return values
void —log()
protected
log(Model|array<string|int, mixed> $models, array<string|int, mixed> $properties, string $description[, null $logName = null ]) : array<string|int, Activity>
Parameters
- $models : Model|array<string|int, mixed>
- $properties : array<string|int, mixed>
- $description : string
- $logName : null = null
Return values
array<string|int, Activity> —assertDependency()
This function will aseert that the resource <-> subresource relation
private
assertDependency(Project $project, Router $router) : void
Parameters
Return values
void —jsonError()
private
static jsonError(int $code, array<string|int, mixed> $errors) : JsonResponse
Parameters
- $code : int
- $errors : array<string|int, mixed>