class RouteCollectionBuilder

Helps add and import routes into a RouteCollection.

Methods

__construct(LoaderInterface $loader = null)

No description

import(mixed $resource, string|null $prefix = '/', string $type = null)

Import an external routing resource and returns the RouteCollectionBuilder.

add(string $path, string $controller, string|null $name = null)

Adds a route and returns it for future modification.

createBuilder()

Returns a RouteCollectionBuilder that can be configured and then added with mount().

mount(string $prefix, RouteCollectionBuilder $builder)

Add a RouteCollectionBuilder.

$this
addRoute(Route $route, string|null $name = null)

Adds a Route object to the builder.

$this
setHost(string $pattern)

Sets the host on all embedded routes (unless already set).

$this
setCondition(string $condition)

Sets a condition on all embedded routes (unless already set).

$this
setDefault(string $key, mixed $value)

Sets a default value that will be added to all embedded routes (unless that default value is already set).

$this
setRequirement(string $key, mixed $regex)

Sets a requirement that will be added to all embedded routes (unless that requirement is already set).

$this
setOption(string $key, mixed $value)

Sets an opiton that will be added to all embedded routes (unless that option is already set).

$this
setSchemes(array|string $schemes)

Sets the schemes on all embedded routes (unless already set).

$this
setMethods(array|string $methods)

Sets the methods on all embedded routes (unless already set).

build()

Creates the final RouteCollection and returns it.

Details

at line 41
__construct(LoaderInterface $loader = null)

Parameters

LoaderInterface $loader

at line 59
RouteCollectionBuilder import(mixed $resource, string|null $prefix = '/', string $type = null)

Import an external routing resource and returns the RouteCollectionBuilder.

$routes->import('blog.yml', '/blog');

Parameters

mixed $resource
string|null $prefix
string $type

Return Value

RouteCollectionBuilder

Exceptions

FileLoaderLoadException

at line 89
Route add(string $path, string $controller, string|null $name = null)

Adds a route and returns it for future modification.

Parameters

string $path The route path
string $controller The route's controller
string|null $name The name to give this route

Return Value

Route

at line 103
RouteCollectionBuilder createBuilder()

Returns a RouteCollectionBuilder that can be configured and then added with mount().

Return Value

RouteCollectionBuilder

at line 114
mount(string $prefix, RouteCollectionBuilder $builder)

Add a RouteCollectionBuilder.

Parameters

string $prefix
RouteCollectionBuilder $builder

at line 128
$this addRoute(Route $route, string|null $name = null)

Adds a Route object to the builder.

Parameters

Route $route
string|null $name

Return Value

$this

at line 147
$this setHost(string $pattern)

Sets the host on all embedded routes (unless already set).

Parameters

string $pattern

Return Value

$this

at line 161
$this setCondition(string $condition)

Sets a condition on all embedded routes (unless already set).

Parameters

string $condition

Return Value

$this

at line 177
$this setDefault(string $key, mixed $value)

Sets a default value that will be added to all embedded routes (unless that default value is already set).

Parameters

string $key
mixed $value

Return Value

$this

at line 193
$this setRequirement(string $key, mixed $regex)

Sets a requirement that will be added to all embedded routes (unless that requirement is already set).

Parameters

string $key
mixed $regex

Return Value

$this

at line 209
$this setOption(string $key, mixed $value)

Sets an opiton that will be added to all embedded routes (unless that option is already set).

Parameters

string $key
mixed $value

Return Value

$this

at line 223
$this setSchemes(array|string $schemes)

Sets the schemes on all embedded routes (unless already set).

Parameters

array|string $schemes

Return Value

$this

at line 237
$this setMethods(array|string $methods)

Sets the methods on all embedded routes (unless already set).

Parameters

array|string $methods

Return Value

$this

at line 263
RouteCollection build()

Creates the final RouteCollection and returns it.

Return Value

RouteCollection