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

__construct(LoaderInterface $loader = null)

Parameters

LoaderInterface $loader

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

LoaderLoadException

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

RouteCollectionBuilder createBuilder()

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

Return Value

RouteCollectionBuilder

mount(string $prefix, RouteCollectionBuilder $builder)

Add a RouteCollectionBuilder.

Parameters

string $prefix
RouteCollectionBuilder $builder

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

Adds a Route object to the builder.

Parameters

Route $route
string|null $name

Return Value

$this

$this setHost(string $pattern)

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

Parameters

string $pattern

Return Value

$this

$this setCondition(string $condition)

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

Parameters

string $condition

Return Value

$this

$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

$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

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

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

Parameters

string $key
mixed $value

Return Value

$this

$this setSchemes(array|string $schemes)

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

Parameters

array|string $schemes

Return Value

$this

$this setMethods(array|string $methods)

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

Parameters

array|string $methods

Return Value

$this

RouteCollection build()

Creates the final RouteCollection and returns it.

Return Value

RouteCollection