Documentation

RouteCollectionBuilder
in package

Helps add and import routes into a RouteCollection.

Tags
author

Ryan Weaver ryan@knpuniversity.com

deprecated

since Symfony 5.1, use RoutingConfigurator instead

Table of Contents

$condition  : mixed
$defaults  : mixed
$host  : mixed
$loader  : mixed
$methods  : mixed
$options  : mixed
$prefix  : mixed
$requirements  : mixed
$resources  : mixed
$routes  : array<string|int, Route>|array<string|int, RouteCollectionBuilder>
$schemes  : mixed
__construct()  : mixed
add()  : Route
Adds a route and returns it for future modification.
addRoute()  : $this
Adds a Route object to the builder.
build()  : RouteCollection
Creates the final RouteCollection and returns it.
createBuilder()  : self
Returns a RouteCollectionBuilder that can be configured and then added with mount().
import()  : self
Import an external routing resource and returns the RouteCollectionBuilder.
mount()  : mixed
Add a RouteCollectionBuilder.
setCondition()  : $this
Sets a condition on all embedded routes (unless already set).
setDefault()  : $this
Sets a default value that will be added to all embedded routes (unless that default value is already set).
setHost()  : $this
Sets the host on all embedded routes (unless already set).
setMethods()  : $this
Sets the methods on all embedded routes (unless already set).
setOption()  : $this
Sets an option that will be added to all embedded routes (unless that option is already set).
setRequirement()  : $this
Sets a requirement that will be added to all embedded routes (unless that requirement is already set).
setSchemes()  : $this
Sets the schemes on all embedded routes (unless already set).
addResource()  : $this
Adds a resource for this collection.
generateRouteName()  : string
Generates a route name based on details of this route.
load()  : array<string|int, RouteCollection>
Finds a loader able to load an imported resource and loads it.

Properties

Methods

add()

Adds a route and returns it for future modification.

public add(string $path, string $controller[, string|null $name = null ]) : Route
Parameters
$path : string
$controller : string
$name : string|null = null
Return values
Route

addRoute()

Adds a Route object to the builder.

public addRoute(Route $route[, string|null $name = null ]) : $this
Parameters
$route : Route
$name : string|null = null
Return values
$this

createBuilder()

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

public createBuilder() : self
Return values
self

import()

Import an external routing resource and returns the RouteCollectionBuilder.

public import(mixed $resource[, string $prefix = '/' ][, string|null $type = null ]) : self

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

Parameters
$resource : mixed
$prefix : string = '/'
$type : string|null = null
Tags
throws
LoaderLoadException
Return values
self

mount()

Add a RouteCollectionBuilder.

public mount(string $prefix, self $builder) : mixed
Parameters
$prefix : string
$builder : self
Return values
mixed

setCondition()

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

public setCondition(string|null $condition) : $this
Parameters
$condition : string|null
Return values
$this

setDefault()

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

public setDefault(string $key, mixed $value) : $this
Parameters
$key : string
$value : mixed
Return values
$this

setHost()

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

public setHost(string|null $pattern) : $this
Parameters
$pattern : string|null
Return values
$this

setMethods()

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

public setMethods(array<string|int, mixed>|string $methods) : $this
Parameters
$methods : array<string|int, mixed>|string
Return values
$this

setOption()

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

public setOption(string $key, mixed $value) : $this
Parameters
$key : string
$value : mixed
Return values
$this

setRequirement()

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

public setRequirement(string $key, mixed $regex) : $this
Parameters
$key : string
$regex : mixed
Return values
$this

setSchemes()

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

public setSchemes(array<string|int, mixed>|string $schemes) : $this
Parameters
$schemes : array<string|int, mixed>|string
Return values
$this

generateRouteName()

Generates a route name based on details of this route.

private generateRouteName(Route $route) : string
Parameters
$route : Route
Return values
string

load()

Finds a loader able to load an imported resource and loads it.

private load(mixed $resource[, string|null $type = null ]) : array<string|int, RouteCollection>
Parameters
$resource : mixed

A resource

$type : string|null = null

The resource type or null if unknown

Tags
throws
LoaderLoadException

If no loader is found

Return values
array<string|int, RouteCollection>

Search results