class ResourceRegistrar (View source)

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 $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

void
__construct(Router $router)

Create a new resource registrar instance.

register(string $name, string $controller, array $options = [])

Route a resource to a controller.

singleton(string $name, string $controller, array $options = [])

Route a singleton resource to a controller.

void
prefixedResource(string $name, string $controller, array $options)

Build a set of prefixed resource routes.

void
prefixedSingleton(string $name, string $controller, array $options)

Build a set of prefixed singleton routes.

array
getResourcePrefix(string $name)

Extract the resource and prefix from a resource name.

array
getResourceMethods(array $defaults, array $options)

Get the applicable resource methods.

addResourceIndex(string $name, string $base, string $controller, array $options)

Add the index method for a resourceful route.

addResourceCreate(string $name, string $base, string $controller, array $options)

Add the create method for a resourceful route.

addResourceStore(string $name, string $base, string $controller, array $options)

Add the store method for a resourceful route.

addResourceShow(string $name, string $base, string $controller, array $options)

Add the show method for a resourceful route.

addResourceEdit(string $name, string $base, string $controller, array $options)

Add the edit method for a resourceful route.

addResourceUpdate(string $name, string $base, string $controller, array $options)

Add the update method for a resourceful route.

addResourceDestroy(string $name, string $base, string $controller, array $options)

Add the destroy method for a resourceful route.

addSingletonCreate(string $name, string $controller, array $options)

Add the create method for a singleton route.

addSingletonStore(string $name, string $controller, array $options)

Add the store method for a singleton route.

addSingletonShow(string $name, string $controller, array $options)

Add the show method for a singleton route.

addSingletonEdit(string $name, string $controller, array $options)

Add the edit method for a singleton route.

addSingletonUpdate(string $name, string $controller, array $options)

Add the update method for a singleton route.

addSingletonDestroy(string $name, string $controller, array $options)

Add the destroy method for a singleton route.

string
getShallowName(string $name, array $options)

Get the name for a given resource with shallowness applied when applicable.

void
setResourceBindingFields(Route $route, array $bindingFields)

Set the route's binding fields if the resource is scoped.

string
getResourceUri(string $resource)

Get the base resource URI for a given resource.

string
getNestedResourceUri(array $segments)

Get the URI for a nested resource segment array.

string
getResourceWildcard(string $value)

Format a resource parameter for usage.

array
getResourceAction(string $resource, string $controller, string $method, array $options)

Get the action array for a resource route.

string
getResourceRouteName(string $resource, string $method, array $options)

Get the name for a given resource.

static void
singularParameters(bool $singular = true)

Set or unset the unmapped global parameters to singular.

static array
getParameters()

Get the global parameter map.

static void
setParameters(array $parameters = [])

Set the global parameter mapping.

static array
verbs(array $verbs = [])

Get or set the action verbs used in the resource URIs.

Details

void __construct(Router $router)

Create a new resource registrar instance.

Parameters

Router $router

Return Value

void

RouteCollection register(string $name, string $controller, array $options = [])

Route a resource to a controller.

Parameters

string $name
string $controller
array $options

Return Value

RouteCollection

RouteCollection singleton(string $name, string $controller, array $options = [])

Route a singleton resource to a controller.

Parameters

string $name
string $controller
array $options

Return Value

RouteCollection

protected void prefixedResource(string $name, string $controller, array $options)

Build a set of prefixed resource routes.

Parameters

string $name
string $controller
array $options

Return Value

void

protected void prefixedSingleton(string $name, string $controller, array $options)

Build a set of prefixed singleton routes.

Parameters

string $name
string $controller
array $options

Return Value

void

protected array getResourcePrefix(string $name)

Extract the resource and prefix from a resource name.

Parameters

string $name

Return Value

array

protected array getResourceMethods(array $defaults, array $options)

Get the applicable resource methods.

Parameters

array $defaults
array $options

Return Value

array

protected Route addResourceIndex(string $name, string $base, string $controller, array $options)

Add the index method for a resourceful route.

Parameters

string $name
string $base
string $controller
array $options

Return Value

Route

protected Route addResourceCreate(string $name, string $base, string $controller, array $options)

Add the create method for a resourceful route.

Parameters

string $name
string $base
string $controller
array $options

Return Value

Route

protected Route addResourceStore(string $name, string $base, string $controller, array $options)

Add the store method for a resourceful route.

Parameters

string $name
string $base
string $controller
array $options

Return Value

Route

protected Route addResourceShow(string $name, string $base, string $controller, array $options)

Add the show method for a resourceful route.

Parameters

string $name
string $base
string $controller
array $options

Return Value

Route

protected Route addResourceEdit(string $name, string $base, string $controller, array $options)

Add the edit method for a resourceful route.

Parameters

string $name
string $base
string $controller
array $options

Return Value

Route

protected Route addResourceUpdate(string $name, string $base, string $controller, array $options)

Add the update method for a resourceful route.

Parameters

string $name
string $base
string $controller
array $options

Return Value

Route

protected Route addResourceDestroy(string $name, string $base, string $controller, array $options)

Add the destroy method for a resourceful route.

Parameters

string $name
string $base
string $controller
array $options

Return Value

Route

protected Route addSingletonCreate(string $name, string $controller, array $options)

Add the create method for a singleton route.

Parameters

string $name
string $controller
array $options

Return Value

Route

protected Route addSingletonStore(string $name, string $controller, array $options)

Add the store method for a singleton route.

Parameters

string $name
string $controller
array $options

Return Value

Route

protected Route addSingletonShow(string $name, string $controller, array $options)

Add the show method for a singleton route.

Parameters

string $name
string $controller
array $options

Return Value

Route

protected Route addSingletonEdit(string $name, string $controller, array $options)

Add the edit method for a singleton route.

Parameters

string $name
string $controller
array $options

Return Value

Route

protected Route addSingletonUpdate(string $name, string $controller, array $options)

Add the update method for a singleton route.

Parameters

string $name
string $controller
array $options

Return Value

Route

protected Route addSingletonDestroy(string $name, string $controller, array $options)

Add the destroy method for a singleton route.

Parameters

string $name
string $controller
array $options

Return Value

Route

protected string getShallowName(string $name, array $options)

Get the name for a given resource with shallowness applied when applicable.

Parameters

string $name
array $options

Return Value

string

protected void setResourceBindingFields(Route $route, array $bindingFields)

Set the route's binding fields if the resource is scoped.

Parameters

Route $route
array $bindingFields

Return Value

void

string getResourceUri(string $resource)

Get the base resource URI for a given resource.

Parameters

string $resource

Return Value

string

protected string getNestedResourceUri(array $segments)

Get the URI for a nested resource segment array.

Parameters

array $segments

Return Value

string

string getResourceWildcard(string $value)

Format a resource parameter for usage.

Parameters

string $value

Return Value

string

protected array getResourceAction(string $resource, string $controller, string $method, array $options)

Get the action array for a resource route.

Parameters

string $resource
string $controller
string $method
array $options

Return Value

array

protected string getResourceRouteName(string $resource, string $method, array $options)

Get the name for a given resource.

Parameters

string $resource
string $method
array $options

Return Value

string

static void singularParameters(bool $singular = true)

Set or unset the unmapped global parameters to singular.

Parameters

bool $singular

Return Value

void

static array getParameters()

Get the global parameter map.

Return Value

array

static void setParameters(array $parameters = [])

Set the global parameter mapping.

Parameters

array $parameters

Return Value

void

static array verbs(array $verbs = [])

Get or set the action verbs used in the resource URIs.

Parameters

array $verbs

Return Value

array