PHP Class Dingo\Api\Routing\Router

Afficher le fichier Open project: dingo/api Class Usage Examples

Protected Properties

Свойство Type Description
$accept Dingo\Api\Http\Parser\Accept Accept parser instance.
$adapter Dingo\Api\Contract\Routing\Adapter Routing adapter instance.
$conditionalRequest boolean Indicates if the request is conditional.
$container Illuminate\Container\Container Application container instance.
$currentRoute Route The current route being dispatched.
$domain string The API domain.
$exception Dingo\Api\Contract\Debug\ExceptionHandler Exception handler instance.
$groupStack array Group stack array.
$prefix string The API prefix.
$routesDispatched integer The number of routes dispatched.

Méthodes publiques

Méthode Description
__construct ( Dingo\Api\Contract\Routing\Adapter $adapter, Dingo\Api\Contract\Debug\ExceptionHandler $exception, Illuminate\Container\Container $container, string $domain, string $prefix ) : void Create a new router instance.
addRoute ( string | array $methods, string $uri, string | array | callable $action ) : mixed Add a route to the routing adapter.
any ( string $uri, array | string | callable $action ) : mixed Create a new route that responding to all verbs.
createRoute ( array | Illuminate\Routing\Route $route ) : Route Create a new route instance from an adapter route.
current ( ) : Illuminate\Routing\Route Get the currently dispatched route instance.
currentRouteAction ( ) : string | null Get the current route action.
currentRouteName ( ) : string | null Get the current route name.
currentRouteNamed ( string $name ) : boolean Determine if the current route matches a given name.
currentRouteUses ( string $action ) : boolean Determine if the current route action matches a given action.
delete ( string $uri, array | string | callable $action ) : mixed Create a new DELETE route.
dispatch ( Dingo\Api\Http\Request $request ) : Response Dispatch a request via the adapter.
gatherRouteMiddlewares ( mixed $route ) : array Gather the middleware for the given route.
get ( string $uri, array | string | callable $action ) : mixed Create a new GET route.
getAdapterRoutes ( ) : array Get the raw adapter routes.
getCurrentRequest ( ) : Dingo\Api\Http\Request Get the current request instance.
getCurrentRoute ( ) : Route Get the current route instance.
getLastGroupPrefix ( ) : string Get the prefix from the last group on the stack.
getRoutes ( string $version = null ) : mixed Get all routes registered on the adapter.
getRoutesDispatched ( ) : integer Get the number of routes dispatched.
group ( array $attributes, callable $callback ) : void Create a new route group.
hasDispatchedRoutes ( ) : boolean Determine if the router has dispatched any routes.
hasGroupStack ( ) : boolean Determine if the router has a group stack.
is ( ) : boolean Alias for the "currentRouteNamed" method.
match ( array | string $methods, string $uri, array | string | callable $action ) : mixed Create a new route with the given verbs.
options ( string $uri, array | string | callable $action ) : mixed Create a new OPTIONS route.
patch ( string $uri, array | string | callable $action ) : mixed Create a new PATCH route.
post ( string $uri, array | string | callable $action ) : mixed Create a new POST route.
put ( string $uri, array | string | callable $action ) : mixed Create a new PUT route.
resource ( string $name, string $controller, array $options = [] ) : void Register a resource controller.
resources ( array $resources ) : void Register an array of resources.
setAdapterRoutes ( array $routes ) : void Set the raw adapter routes.
setConditionalRequest ( boolean $conditionalRequest ) : void Set the conditional request.
setCurrentRoute ( Route $route ) : void Set the current route instance.
uses ( ) : boolean Alias for the "currentRouteUses" method.
version ( string $version, array | callable $second, callable $third = null ) : void An alias for calling the group method, allows a more fluent API for registering a new API version group with optional attributes and a required callback.

Méthodes protégées

Méthode Description
addControllerMiddlewareToRouteAction ( array $action ) : array Add the controller preparation middleware to the beginning of the routes middleware.
formatArrayBasedOption ( string $option, array $new ) : array Format an array based option in a route action.
formatNamespace ( array $new, array $old ) : string Format the namespace for the new group attributes.
formatPrefix ( array $new, array $old ) : string Format the prefix for the new group attributes.
formatUses ( array $new, array $old ) : string Format the uses key in a route action.
mergeGroup ( array $new, array $old ) : array Merge the given group attributes.
mergeLastGroupAttributes ( array $attributes ) : array Merge the last groups attributes.
prepareResponse ( mixed $response, Dingo\Api\Http\Request $request, string $format ) : Response Prepare a response by transforming and formatting it correctly.
requestIsConditional ( ) : boolean Determine if the request is conditional.

Method Details

__construct() public méthode

Create a new router instance.
public __construct ( Dingo\Api\Contract\Routing\Adapter $adapter, Dingo\Api\Contract\Debug\ExceptionHandler $exception, Illuminate\Container\Container $container, string $domain, string $prefix ) : void
$adapter Dingo\Api\Contract\Routing\Adapter
$exception Dingo\Api\Contract\Debug\ExceptionHandler
$container Illuminate\Container\Container
$domain string
$prefix string
Résultat void

addControllerMiddlewareToRouteAction() protected méthode

Add the controller preparation middleware to the beginning of the routes middleware.
protected addControllerMiddlewareToRouteAction ( array $action ) : array
$action array
Résultat array

addRoute() public méthode

Add a route to the routing adapter.
public addRoute ( string | array $methods, string $uri, string | array | callable $action ) : mixed
$methods string | array
$uri string
$action string | array | callable
Résultat mixed

any() public méthode

Create a new route that responding to all verbs.
public any ( string $uri, array | string | callable $action ) : mixed
$uri string
$action array | string | callable
Résultat mixed

createRoute() public méthode

Create a new route instance from an adapter route.
public createRoute ( array | Illuminate\Routing\Route $route ) : Route
$route array | Illuminate\Routing\Route
Résultat Route

current() public méthode

Get the currently dispatched route instance.
public current ( ) : Illuminate\Routing\Route
Résultat Illuminate\Routing\Route

currentRouteAction() public méthode

Get the current route action.
public currentRouteAction ( ) : string | null
Résultat string | null

currentRouteName() public méthode

Get the current route name.
public currentRouteName ( ) : string | null
Résultat string | null

currentRouteNamed() public méthode

Determine if the current route matches a given name.
public currentRouteNamed ( string $name ) : boolean
$name string
Résultat boolean

currentRouteUses() public méthode

Determine if the current route action matches a given action.
public currentRouteUses ( string $action ) : boolean
$action string
Résultat boolean

delete() public méthode

Create a new DELETE route.
public delete ( string $uri, array | string | callable $action ) : mixed
$uri string
$action array | string | callable
Résultat mixed

dispatch() public méthode

Dispatch a request via the adapter.
public dispatch ( Dingo\Api\Http\Request $request ) : Response
$request Dingo\Api\Http\Request
Résultat Dingo\Api\Http\Response

formatArrayBasedOption() protected méthode

Format an array based option in a route action.
protected formatArrayBasedOption ( string $option, array $new ) : array
$option string
$new array
Résultat array

formatNamespace() protected méthode

Format the namespace for the new group attributes.
protected formatNamespace ( array $new, array $old ) : string
$new array
$old array
Résultat string

formatPrefix() protected méthode

Format the prefix for the new group attributes.
protected formatPrefix ( array $new, array $old ) : string
$new array
$old array
Résultat string

formatUses() protected méthode

Format the uses key in a route action.
protected formatUses ( array $new, array $old ) : string
$new array
$old array
Résultat string

gatherRouteMiddlewares() public méthode

Gather the middleware for the given route.
public gatherRouteMiddlewares ( mixed $route ) : array
$route mixed
Résultat array

get() public méthode

Create a new GET route.
public get ( string $uri, array | string | callable $action ) : mixed
$uri string
$action array | string | callable
Résultat mixed

getAdapterRoutes() public méthode

Get the raw adapter routes.
public getAdapterRoutes ( ) : array
Résultat array

getCurrentRequest() public méthode

Get the current request instance.
public getCurrentRequest ( ) : Dingo\Api\Http\Request
Résultat Dingo\Api\Http\Request

getCurrentRoute() public méthode

Get the current route instance.
public getCurrentRoute ( ) : Route
Résultat Route

getLastGroupPrefix() public méthode

Get the prefix from the last group on the stack.
public getLastGroupPrefix ( ) : string
Résultat string

getRoutes() public méthode

Get all routes registered on the adapter.
public getRoutes ( string $version = null ) : mixed
$version string
Résultat mixed

getRoutesDispatched() public méthode

Get the number of routes dispatched.
public getRoutesDispatched ( ) : integer
Résultat integer

group() public méthode

Create a new route group.
public group ( array $attributes, callable $callback ) : void
$attributes array
$callback callable
Résultat void

hasDispatchedRoutes() public méthode

Determine if the router has dispatched any routes.
public hasDispatchedRoutes ( ) : boolean
Résultat boolean

hasGroupStack() public méthode

Determine if the router has a group stack.
public hasGroupStack ( ) : boolean
Résultat boolean

is() public méthode

Alias for the "currentRouteNamed" method.
public is ( ) : boolean
Résultat boolean

match() public méthode

Create a new route with the given verbs.
public match ( array | string $methods, string $uri, array | string | callable $action ) : mixed
$methods array | string
$uri string
$action array | string | callable
Résultat mixed

mergeGroup() protected méthode

Merge the given group attributes.
protected mergeGroup ( array $new, array $old ) : array
$new array
$old array
Résultat array

mergeLastGroupAttributes() protected méthode

Merge the last groups attributes.
protected mergeLastGroupAttributes ( array $attributes ) : array
$attributes array
Résultat array

options() public méthode

Create a new OPTIONS route.
public options ( string $uri, array | string | callable $action ) : mixed
$uri string
$action array | string | callable
Résultat mixed

patch() public méthode

Create a new PATCH route.
public patch ( string $uri, array | string | callable $action ) : mixed
$uri string
$action array | string | callable
Résultat mixed

post() public méthode

Create a new POST route.
public post ( string $uri, array | string | callable $action ) : mixed
$uri string
$action array | string | callable
Résultat mixed

prepareResponse() protected méthode

Prepare a response by transforming and formatting it correctly.
protected prepareResponse ( mixed $response, Dingo\Api\Http\Request $request, string $format ) : Response
$response mixed
$request Dingo\Api\Http\Request
$format string
Résultat Dingo\Api\Http\Response

put() public méthode

Create a new PUT route.
public put ( string $uri, array | string | callable $action ) : mixed
$uri string
$action array | string | callable
Résultat mixed

requestIsConditional() protected méthode

Determine if the request is conditional.
protected requestIsConditional ( ) : boolean
Résultat boolean

resource() public méthode

Register a resource controller.
public resource ( string $name, string $controller, array $options = [] ) : void
$name string
$controller string
$options array
Résultat void

resources() public méthode

Register an array of resources.
public resources ( array $resources ) : void
$resources array
Résultat void

setAdapterRoutes() public méthode

Set the raw adapter routes.
public setAdapterRoutes ( array $routes ) : void
$routes array
Résultat void

setConditionalRequest() public méthode

Set the conditional request.
public setConditionalRequest ( boolean $conditionalRequest ) : void
$conditionalRequest boolean
Résultat void

setCurrentRoute() public méthode

Set the current route instance.
public setCurrentRoute ( Route $route ) : void
$route Route
Résultat void

uses() public méthode

Alias for the "currentRouteUses" method.
public uses ( ) : boolean
Résultat boolean

version() public méthode

This method can be called without the third parameter, however, the callback should always be the last paramter.
public version ( string $version, array | callable $second, callable $third = null ) : void
$version string
$second array | callable
$third callable
Résultat void

Property Details

$accept protected_oe property

Accept parser instance.
protected Accept,Dingo\Api\Http\Parser $accept
Résultat Dingo\Api\Http\Parser\Accept

$adapter protected_oe property

Routing adapter instance.
protected Adapter,Dingo\Api\Contract\Routing $adapter
Résultat Dingo\Api\Contract\Routing\Adapter

$conditionalRequest protected_oe property

Indicates if the request is conditional.
protected bool $conditionalRequest
Résultat boolean

$container protected_oe property

Application container instance.
protected Container,Illuminate\Container $container
Résultat Illuminate\Container\Container

$currentRoute protected_oe property

The current route being dispatched.
protected Route,Dingo\Api\Routing $currentRoute
Résultat Route

$domain protected_oe property

The API domain.
protected string $domain
Résultat string

$exception protected_oe property

Exception handler instance.
protected ExceptionHandler,Dingo\Api\Contract\Debug $exception
Résultat Dingo\Api\Contract\Debug\ExceptionHandler

$groupStack protected_oe property

Group stack array.
protected array $groupStack
Résultat array

$prefix protected_oe property

The API prefix.
protected string $prefix
Résultat string

$routesDispatched protected_oe property

The number of routes dispatched.
protected int $routesDispatched
Résultat integer