Class

Silex\ControllerCollection

class ControllerCollection

Builds Silex controllers.

It acts as a staging area for routes. You are able to set the route name until flush() is called, at which point all controllers are frozen and converted to a RouteCollection.

__call() forwards method-calls to Route, but returns instance of ControllerCollection listing Route's methods below, so that IDEs know they are valid

Methods

__construct(Route $defaultRoute)

Constructor.

mount(string $prefix, ControllerCollection $controllers)

Mounts controllers under the given route prefix.

Controller match(string $pattern, mixed $to = null)

Maps a pattern to a callable.

Controller get(string $pattern, mixed $to = null)

Maps a GET request to a callable.

Controller post(string $pattern, mixed $to = null)

Maps a POST request to a callable.

Controller put(string $pattern, mixed $to = null)

Maps a PUT request to a callable.

Controller delete(string $pattern, mixed $to = null)

Maps a DELETE request to a callable.

Controller patch(string $pattern, mixed $to = null)

Maps a PATCH request to a callable.

__call($method, $arguments)

RouteCollection flush(string $prefix = '')

Persists and freezes staged controllers.

ControllerCollection assert(string $variable, string $regexp)

ControllerCollection value(string $variable, mixed $default)

ControllerCollection convert(string $variable, mixed $callback)

ControllerCollection method(string $method)

ControllerCollection requireHttp()

ControllerCollection requireHttps()

ControllerCollection before(mixed $callback)

ControllerCollection after(mixed $callback)

Details

at line 49
public __construct(Route $defaultRoute)

Constructor.

Parameters

Route $defaultRoute

at line 63
public mount(string $prefix, ControllerCollection $controllers)

Mounts controllers under the given route prefix.

Parameters

string $prefix The route prefix
ControllerCollection $controllers A ControllerCollection instance

at line 80
public Controller match(string $pattern, mixed $to = null)

Maps a pattern to a callable.

You can optionally specify HTTP methods that should be matched.

Parameters

string $pattern Matched route pattern
mixed $to Callback that returns the response when matched

Return Value

Controller

at line 98
public Controller get(string $pattern, mixed $to = null)

Maps a GET request to a callable.

Parameters

string $pattern Matched route pattern
mixed $to Callback that returns the response when matched

Return Value

Controller

at line 111
public Controller post(string $pattern, mixed $to = null)

Maps a POST request to a callable.

Parameters

string $pattern Matched route pattern
mixed $to Callback that returns the response when matched

Return Value

Controller

at line 124
public Controller put(string $pattern, mixed $to = null)

Maps a PUT request to a callable.

Parameters

string $pattern Matched route pattern
mixed $to Callback that returns the response when matched

Return Value

Controller

at line 137
public Controller delete(string $pattern, mixed $to = null)

Maps a DELETE request to a callable.

Parameters

string $pattern Matched route pattern
mixed $to Callback that returns the response when matched

Return Value

Controller

at line 150
public Controller patch(string $pattern, mixed $to = null)

Maps a PATCH request to a callable.

Parameters

string $pattern Matched route pattern
mixed $to Callback that returns the response when matched

Return Value

Controller

at line 155
public __call($method, $arguments)

Parameters

$method
$arguments

at line 179
public RouteCollection flush(string $prefix = '')

Persists and freezes staged controllers.

Parameters

string $prefix

Return Value

RouteCollection A RouteCollection instance

at line 39
ControllerCollection assert(string $variable, string $regexp)

Parameters

string $variable
string $regexp

Return Value

ControllerCollection

at line 39
ControllerCollection value(string $variable, mixed $default)

Parameters

string $variable
mixed $default

Return Value

ControllerCollection

at line 39
ControllerCollection convert(string $variable, mixed $callback)

Parameters

string $variable
mixed $callback

Return Value

ControllerCollection

at line 39
ControllerCollection method(string $method)

Parameters

string $method

Return Value

ControllerCollection

at line 39
ControllerCollection requireHttp()

Return Value

ControllerCollection

at line 39
ControllerCollection requireHttps()

Return Value

ControllerCollection

at line 39
ControllerCollection before(mixed $callback)

Parameters

mixed $callback

Return Value

ControllerCollection

at line 39
ControllerCollection after(mixed $callback)

Parameters

mixed $callback

Return Value

ControllerCollection