PHP Class Symfony\Component\Routing\Router

Author: Fabien Potencier ([email protected])
Inheritance: implements Symfony\Component\Routing\RouterInterface, implements Symfony\Component\Routing\Matcher\RequestMatcherInterface
Show file Open project: pmjones/php-framework-benchmarks Class Usage Examples

Protected Properties

Property Type Description
$collection
$context
$defaults
$generator
$loader
$matcher
$options
$resource

Public Methods

Method Description
__construct ( Symfony\Component\Config\Loader\LoaderInterface $loader, mixed $resource, array $options = [], Symfony\Component\Routing\RequestContext $context = null, array $defaults = [] ) Constructor.
generate ( string $name, array $parameters = [], boolean $absolute = false ) : string Generates a URL from the given parameters.
getContext ( ) : Symfony\Component\Routing\RequestContext Gets the request context.
getGenerator ( ) : UrlGeneratorInterface Gets the UrlGenerator instance associated with this Router.
getMatcher ( ) : UrlMatcherInterface Gets the UrlMatcher instance associated with this Router.
getOption ( string $key ) : mixed Gets an option value.
getRouteCollection ( ) : RouteCollection Gets the RouteCollection instance associated with this Router.
match ( string $url ) : array | false Tries to match a URL with a set of routes.
setContext ( Symfony\Component\Routing\RequestContext $context ) Sets the request context.
setOption ( string $key, mixed $value ) Sets an option.
setOptions ( array $options ) Sets options.

Method Details

__construct() public method

Constructor.
public __construct ( Symfony\Component\Config\Loader\LoaderInterface $loader, mixed $resource, array $options = [], Symfony\Component\Routing\RequestContext $context = null, array $defaults = [] )
$loader Symfony\Component\Config\Loader\LoaderInterface A LoaderInterface instance
$resource mixed The main resource to load
$options array An array of options
$context Symfony\Component\Routing\RequestContext The context
$defaults array The default values

generate() public method

Generates a URL from the given parameters.
public generate ( string $name, array $parameters = [], boolean $absolute = false ) : string
$name string The name of the route
$parameters array An array of parameters
$absolute boolean Whether to generate an absolute URL
return string The generated URL

getContext() public method

Gets the request context.
public getContext ( ) : Symfony\Component\Routing\RequestContext
return Symfony\Component\Routing\RequestContext The context

getGenerator() public method

Gets the UrlGenerator instance associated with this Router.
public getGenerator ( ) : UrlGeneratorInterface
return UrlGeneratorInterface A UrlGeneratorInterface instance

getMatcher() public method

Gets the UrlMatcher instance associated with this Router.
public getMatcher ( ) : UrlMatcherInterface
return UrlMatcherInterface A UrlMatcherInterface instance

getOption() public method

Gets an option value.
public getOption ( string $key ) : mixed
$key string The key
return mixed The value

getRouteCollection() public method

Gets the RouteCollection instance associated with this Router.
public getRouteCollection ( ) : RouteCollection
return RouteCollection A RouteCollection instance

match() public method

Returns false if no route matches the URL.
public match ( string $url ) : array | false
$url string URL to be parsed
return array | false An array of parameters or false if no route matches

setContext() public method

Sets the request context.
public setContext ( Symfony\Component\Routing\RequestContext $context )
$context Symfony\Component\Routing\RequestContext The context

setOption() public method

Sets an option.
public setOption ( string $key, mixed $value )
$key string The key
$value mixed The value

setOptions() public method

Available options: * cache_dir: The cache directory (or null to disable caching) * debug: Whether to enable debugging or not (false by default) * resource_type: Type hint for the main resource (optional)
public setOptions ( array $options )
$options array An array of options

Property Details

$collection protected property

protected $collection

$context protected property

protected $context

$defaults protected property

protected $defaults

$generator protected property

protected $generator

$loader protected property

protected $loader

$matcher protected property

protected $matcher

$options protected property

protected $options

$resource protected property

protected $resource