FastApiController
in package
Uses
ApiResponse
FastApiController class
Table of Contents
Properties
- $container : Container|null
- Container
- $errors : array<string|int, mixed>
- Errors list
- $response : ResponseInterface|null
- Response
- $result : array<string|int, mixed>
- Response result
Methods
- __construct() : mixed
- Constructor
- addError() : void
- Add error
- clearResult() : void
- Clear result
- field() : self
- Set result field
- fields() : self
- Set fields
- getResponse() : ResponseInterface
- Return response
- getResponseJson() : string
- Return json
- hasError() : bool
- Return true if response have error
- setHttpResponse() : void
- Set http response instance
- setResponse() : mixed
- Set response
- setResult() : self
- Set response result
- setResultField() : void
- Set field to result array
- setResultFields() : void
- Set result filelds
Properties
$container
Container
protected
Container|null
$container
= null
$errors
Errors list
protected
array<string|int, mixed>
$errors
= []
$response
Response
protected
ResponseInterface|null
$response
= null
$result
Response result
protected
array<string|int, mixed>
$result
Methods
__construct()
Constructor
public
__construct([Container|null $container = null ]) : mixed
Parameters
- $container : Container|null = null
addError()
Add error
public
addError(string $message) : void
Parameters
- $message : string
clearResult()
Clear result
public
clearResult() : void
field()
Set result field
public
field(string $name, mixed $value) : self
Parameters
- $name : string
- $value : mixed
Return values
selffields()
Set fields
public
fields(array<string|int, mixed> $data[, string|null $filedName = null ]) : self
Parameters
- $data : array<string|int, mixed>
- $filedName : string|null = null
Return values
selfgetResponse()
Return response
public
getResponse([bool $raw = false ][, ResponseInterface|null $response = null ][, bool $progress = false ]) : ResponseInterface
Parameters
- $raw : bool = false
- $response : ResponseInterface|null = null
- $progress : bool = false
Return values
ResponseInterfacegetResponseJson()
Return json
public
getResponseJson([bool $raw = false ]) : string
Parameters
- $raw : bool = false
Return values
stringhasError()
Return true if response have error
public
hasError() : bool
Return values
boolsetHttpResponse()
Set http response instance
public
setHttpResponse(ResponseInterface $response) : void
Parameters
- $response : ResponseInterface
setResponse()
Set response
public
setResponse(mixed $condition, array<string|int, mixed>|string|Closure $data, string|Closure $error) : mixed
Parameters
- $condition : mixed
- $data : array<string|int, mixed>|string|Closure
- $error : string|Closure
setResult()
Set response result
public
setResult(mixed $data) : self
Parameters
- $data : mixed
Return values
selfsetResultField()
Set field to result array
public
setResultField(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
setResultFields()
Set result filelds
public
setResultFields(array<string|int, mixed> $values[, string|null $filedName = null ]) : void
Parameters
- $values : array<string|int, mixed>
- $filedName : string|null = null