ResourceRegistrar
class ResourceRegistrar
Constants
| protected DEFAULT_VERBS |
The default verbs used in resource URIs. |
Properties
| protected Router | $router | The router instance. |
|
| protected string[] | $resourceDefaults | The default actions for a resourceful controller. |
|
| protected string[] | $singletonResourceDefaults | The default actions for a singleton resource controller. |
|
| protected array|string|null | $parameters | The parameters set for this resource instance. |
|
| static protected array | $parameterMap | The global parameter mapping. |
|
| static protected bool | $singularParameters | Singular global parameters. |
|
| static protected array | $verbs | The verbs used in the resource URIs. |
Methods
Route a resource to a controller.
Route a singleton resource to a controller.
Build a set of prefixed resource routes.
Build a set of prefixed singleton routes.
Extract the resource and prefix from a resource name.
Get the applicable resource methods.
Add the index method for a resourceful route.
Add the create method for a resourceful route.
Add the store method for a resourceful route.
Add the show method for a resourceful route.
Add the edit method for a resourceful route.
Add the update method for a resourceful route.
Add the destroy method for a resourceful route.
Add the create method for a singleton route.
Add the store method for a singleton route.
Add the show method for a singleton route.
Add the edit method for a singleton route.
Add the update method for a singleton route.
Add the destroy method for a singleton route.
Get the name for a given resource with shallowness applied when applicable.
Set the route's binding fields if the resource is scoped.
Get the base resource URI for a given resource.
Get the URI for a nested resource segment array.
Format a resource parameter for usage.
Get the action array for a resource route.
Get the name for a given resource.
Set or unset the unmapped global parameters to singular.
Get the global parameter map.
Set the global parameter mapping.
Get or set the action verbs used in the resource URIs.
Flush all static state.
Details
at line 61
__construct(Router $router)
Create a new resource registrar instance.
at line 69
RouteCollection|null
register(string $name, string $controller, array $options = [])
Route a resource to a controller.
at line 134
RouteCollection|null
singleton(string $name, string $controller, array $options = [])
Route a singleton resource to a controller.
at line 194
protected Router
prefixedResource(string $name, string $controller, array $options)
Build a set of prefixed resource routes.
at line 211
protected Router
prefixedSingleton(string $name, string $controller, array $options)
Build a set of prefixed singleton routes.
at line 228
protected array
getResourcePrefix(string $name)
Extract the resource and prefix from a resource name.
at line 243
protected array
getResourceMethods(array $defaults, array $options)
Get the applicable resource methods.
at line 261
protected Route
addResourceIndex(string $name, string $base, string $controller, array $options)
Add the index method for a resourceful route.
at line 275
protected Route
addResourceCreate(string $name, string $base, string $controller, array $options)
Add the create method for a resourceful route.
at line 289
protected Route
addResourceStore(string $name, string $base, string $controller, array $options)
Add the store method for a resourceful route.
at line 303
protected Route
addResourceShow(string $name, string $base, string $controller, array $options)
Add the show method for a resourceful route.
at line 317
protected Route
addResourceEdit(string $name, string $base, string $controller, array $options)
Add the edit method for a resourceful route.
at line 331
protected Route
addResourceUpdate(string $name, string $base, string $controller, array $options)
Add the update method for a resourceful route.
at line 345
protected Route
addResourceDestroy(string $name, string $base, string $controller, array $options)
Add the destroy method for a resourceful route.
at line 359
protected Route
addSingletonCreate(string $name, string $controller, array $options)
Add the create method for a singleton route.
at line 373
protected Route
addSingletonStore(string $name, string $controller, array $options)
Add the store method for a singleton route.
at line 387
protected Route
addSingletonShow(string $name, string $controller, array $options)
Add the show method for a singleton route.
at line 401
protected Route
addSingletonEdit(string $name, string $controller, array $options)
Add the edit method for a singleton route.
at line 415
protected Route
addSingletonUpdate(string $name, string $controller, array $options)
Add the update method for a singleton route.
at line 429
protected Route
addSingletonDestroy(string $name, string $controller, array $options)
Add the destroy method for a singleton route.
at line 443
protected string
getShallowName(string $name, array $options)
Get the name for a given resource with shallowness applied when applicable.
at line 453
protected void
setResourceBindingFields(Route $route, array $bindingFields)
Set the route's binding fields if the resource is scoped.
at line 468
string
getResourceUri(string $resource)
Get the base resource URI for a given resource.
at line 487
protected string
getNestedResourceUri(array $segments)
Get the URI for a nested resource segment array.
at line 500
string
getResourceWildcard(string $value)
Format a resource parameter for usage.
at line 516
protected array
getResourceAction(string $resource, string $controller, string $method, array $options)
Get the action array for a resource route.
at line 544
protected string
getResourceRouteName(string $resource, string $method, array $options)
Get the name for a given resource.
at line 573
static void
singularParameters(bool $singular = true)
Set or unset the unmapped global parameters to singular.
Boot-only. The flag persists in a static property for the worker lifetime and applies to every subsequent resource-route registration.
at line 581
static array
getParameters()
Get the global parameter map.
at line 592
static void
setParameters(array $parameters = [])
Set the global parameter mapping.
Boot-only. The map persists in a static property for the worker lifetime and applies to every subsequent resource-route registration.
at line 603
static array
verbs(array $verbs = [])
Get or set the action verbs used in the resource URIs.
Boot-only when setting. Verbs persist in a static property for the worker lifetime and apply to every subsequent resource-route URI.
at line 617
static void
flushState()
Flush all static state.