PHP Class Dingo\Api\Dispatcher

Show file Open project: dingo/api Class Usage Examples

Protected Properties

Property Type Description
$auth Dingo\Api\Auth\Auth Auth instance.
$container Illuminate\Container\Container Illuminate container instance.
$content string Request raw content.
$cookies array Request cookies.
$defaultDomain string Default domain.
$defaultFormat string Default format.
$defaultVersion string Default version.
$domain string Domain for the request.
$files Illuminate\Filesystem\Filesystem Illuminate filesystem instance.
$headers array Request headers.
$parameters array Request parameters.
$persistAuthentication boolean Indicates whether authentication is persisted.
$prefix string API prefix.
$raw boolean Indicates whether the returned response is the raw response object.
$requestStack array Internal request stack.
$routeStack array Internal route stack.
$router Dingo\Api\Routing\Router Router instance.
$standardsTree string API standards tree.
$subtype string API subtype.
$uploads array Request uploaded files.
$version string Version for the request.

Public Methods

Method Description
__construct ( Illuminate\Container\Container $container, Illuminate\Filesystem\Filesystem $files, Router $router, Dingo\Api\Auth\Auth $auth ) : void Create a new dispatcher instance.
attach ( array $files ) : Dispatcher Attach files to be uploaded.
be ( mixed $user ) : Dispatcher Internal request will be authenticated as the given user.
cookie ( Cookie $cookie ) : Dispatcher Set a cookie to be sent on the next API request.
delete ( string $uri, string | array $parameters = [], string $content = '' ) : mixed Perform API DELETE request.
get ( string $uri, string | array $parameters = [] ) : mixed Perform API GET request.
getDomain ( ) : string Get the domain.
getFormat ( ) : string Get the format.
getStandardsTree ( ) : string Get the standards tree.
getSubtype ( ) : string Get the subtype.
getVersion ( ) : string Get the version.
header ( string $key, string $value ) : Dispatcher Set a header to be sent on the next API request.
json ( string | array $content ) : Dispatcher Send a JSON payload in the request body.
on ( string $domain ) : Dispatcher Sets the domain to be used for the request.
once ( ) : Dispatcher Only authenticate with the given user for a single request.
patch ( string $uri, string | array $parameters = [], string $content = '' ) : mixed Perform API PATCH request.
post ( string $uri, string | array $parameters = [], string $content = '' ) : mixed Perform API POST request.
put ( string $uri, string | array $parameters = [], string $content = '' ) : mixed Perform API PUT request.
raw ( ) : Dispatcher Return the raw response object once request is dispatched.
setDefaultDomain ( string $domain ) : void Set the default domain.
setDefaultFormat ( string $format ) : void Set the defult format.
setDefaultVersion ( string $version ) : void Set the default version.
setPrefix ( string $prefix ) : void Set the prefix.
setStandardsTree ( string $standardsTree ) : void Set the standards tree.
setSubtype ( string $subtype ) : void Set the subtype.
version ( string $version ) : Dispatcher Set the version of the API for the next request.
with ( string | array $parameters ) : Dispatcher Set the parameters to be sent on the next API request.

Protected Methods

Method Description
addPrefixToUri ( string $uri ) : string Add the prefix to the URI.
clearCachedFacadeInstance ( ) : void Clear the cached facade instance.
createRequest ( string $verb, string $uri, string | array $parameters ) : Dingo\Api\Http\InternalRequest Create a new internal request from an HTTP verb and URI.
dispatch ( Dingo\Api\Http\InternalRequest $request ) : mixed Attempt to dispatch an internal request.
getAcceptHeader ( ) : string Build the "Accept" header.
getRootRequest ( ) : Illuminate\Http\Request Get the root request instance.
queueRequest ( string $verb, string $uri, string | array $parameters, string $content = '' ) : mixed Queue up and dispatch a new request.
refreshRequestStack ( ) : void Refresh the request stack.
replaceRequestInstance ( ) : void Replace the request instance with the previous request instance.
setupRequestStack ( ) : void Setup the request stack by grabbing the initial request.

Method Details

__construct() public method

Create a new dispatcher instance.
public __construct ( Illuminate\Container\Container $container, Illuminate\Filesystem\Filesystem $files, Router $router, Dingo\Api\Auth\Auth $auth ) : void
$container Illuminate\Container\Container
$files Illuminate\Filesystem\Filesystem
$router Dingo\Api\Routing\Router
$auth Dingo\Api\Auth\Auth
return void

addPrefixToUri() protected method

Add the prefix to the URI.
protected addPrefixToUri ( string $uri ) : string
$uri string
return string

attach() public method

Attach files to be uploaded.
public attach ( array $files ) : Dispatcher
$files array
return Dispatcher

be() public method

Internal request will be authenticated as the given user.
public be ( mixed $user ) : Dispatcher
$user mixed
return Dispatcher

clearCachedFacadeInstance() protected method

Clear the cached facade instance.
protected clearCachedFacadeInstance ( ) : void
return void

createRequest() protected method

Create a new internal request from an HTTP verb and URI.
protected createRequest ( string $verb, string $uri, string | array $parameters ) : Dingo\Api\Http\InternalRequest
$verb string
$uri string
$parameters string | array
return Dingo\Api\Http\InternalRequest

delete() public method

Perform API DELETE request.
public delete ( string $uri, string | array $parameters = [], string $content = '' ) : mixed
$uri string
$parameters string | array
$content string
return mixed

dispatch() protected method

Attempt to dispatch an internal request.
protected dispatch ( Dingo\Api\Http\InternalRequest $request ) : mixed
$request Dingo\Api\Http\InternalRequest
return mixed

get() public method

Perform API GET request.
public get ( string $uri, string | array $parameters = [] ) : mixed
$uri string
$parameters string | array
return mixed

getAcceptHeader() protected method

Build the "Accept" header.
protected getAcceptHeader ( ) : string
return string

getDomain() public method

Get the domain.
public getDomain ( ) : string
return string

getFormat() public method

Get the format.
public getFormat ( ) : string
return string

getRootRequest() protected method

Get the root request instance.
protected getRootRequest ( ) : Illuminate\Http\Request
return Illuminate\Http\Request

getStandardsTree() public method

Get the standards tree.
public getStandardsTree ( ) : string
return string

getSubtype() public method

Get the subtype.
public getSubtype ( ) : string
return string

getVersion() public method

Get the version.
public getVersion ( ) : string
return string

header() public method

Set a header to be sent on the next API request.
public header ( string $key, string $value ) : Dispatcher
$key string
$value string
return Dispatcher

json() public method

Send a JSON payload in the request body.
public json ( string | array $content ) : Dispatcher
$content string | array
return Dispatcher

on() public method

Sets the domain to be used for the request.
public on ( string $domain ) : Dispatcher
$domain string
return Dispatcher

once() public method

Only authenticate with the given user for a single request.
public once ( ) : Dispatcher
return Dispatcher

patch() public method

Perform API PATCH request.
public patch ( string $uri, string | array $parameters = [], string $content = '' ) : mixed
$uri string
$parameters string | array
$content string
return mixed

post() public method

Perform API POST request.
public post ( string $uri, string | array $parameters = [], string $content = '' ) : mixed
$uri string
$parameters string | array
$content string
return mixed

put() public method

Perform API PUT request.
public put ( string $uri, string | array $parameters = [], string $content = '' ) : mixed
$uri string
$parameters string | array
$content string
return mixed

queueRequest() protected method

Queue up and dispatch a new request.
protected queueRequest ( string $verb, string $uri, string | array $parameters, string $content = '' ) : mixed
$verb string
$uri string
$parameters string | array
$content string
return mixed

raw() public method

Return the raw response object once request is dispatched.
public raw ( ) : Dispatcher
return Dispatcher

refreshRequestStack() protected method

This is done by resetting the authentication, popping the last request from the stack, replacing the input, and resetting the version and parameters.
protected refreshRequestStack ( ) : void
return void

replaceRequestInstance() protected method

Replace the request instance with the previous request instance.
protected replaceRequestInstance ( ) : void
return void

setDefaultDomain() public method

Set the default domain.
public setDefaultDomain ( string $domain ) : void
$domain string
return void

setDefaultFormat() public method

Set the defult format.
public setDefaultFormat ( string $format ) : void
$format string
return void

setDefaultVersion() public method

Set the default version.
public setDefaultVersion ( string $version ) : void
$version string
return void

setPrefix() public method

Set the prefix.
public setPrefix ( string $prefix ) : void
$prefix string
return void

setStandardsTree() public method

Set the standards tree.
public setStandardsTree ( string $standardsTree ) : void
$standardsTree string
return void

setSubtype() public method

Set the subtype.
public setSubtype ( string $subtype ) : void
$subtype string
return void

setupRequestStack() protected method

Setup the request stack by grabbing the initial request.
protected setupRequestStack ( ) : void
return void

version() public method

Set the version of the API for the next request.
public version ( string $version ) : Dispatcher
$version string
return Dispatcher

with() public method

Set the parameters to be sent on the next API request.
public with ( string | array $parameters ) : Dispatcher
$parameters string | array
return Dispatcher

Property Details

$auth protected property

Auth instance.
protected Auth,Dingo\Api\Auth $auth
return Dingo\Api\Auth\Auth

$container protected property

Illuminate container instance.
protected Container,Illuminate\Container $container
return Illuminate\Container\Container

$content protected property

Request raw content.
protected string $content
return string

$cookies protected property

Request cookies.
protected array $cookies
return array

$defaultDomain protected property

Default domain.
protected string $defaultDomain
return string

$defaultFormat protected property

Default format.
protected string $defaultFormat
return string

$defaultVersion protected property

Default version.
protected string $defaultVersion
return string

$domain protected property

Domain for the request.
protected string $domain
return string

$files protected property

Illuminate filesystem instance.
protected Filesystem,Illuminate\Filesystem $files
return Illuminate\Filesystem\Filesystem

$headers protected property

Request headers.
protected array $headers
return array

$parameters protected property

Request parameters.
protected array $parameters
return array

$persistAuthentication protected property

Indicates whether authentication is persisted.
protected bool $persistAuthentication
return boolean

$prefix protected property

API prefix.
protected string $prefix
return string

$raw protected property

Indicates whether the returned response is the raw response object.
protected bool $raw
return boolean

$requestStack protected property

Internal request stack.
protected array $requestStack
return array

$routeStack protected property

Internal route stack.
protected array $routeStack
return array

$router protected property

Router instance.
protected Router,Dingo\Api\Routing $router
return Dingo\Api\Routing\Router

$standardsTree protected property

API standards tree.
protected string $standardsTree
return string

$subtype protected property

API subtype.
protected string $subtype
return string

$uploads protected property

Request uploaded files.
protected array $uploads
return array

$version protected property

Version for the request.
protected string $version
return string