PHP Class Symfony\Component\Routing\RouteCollection

When adding a route, it overrides existing routes with the same name defined in the instance or its children and parents.
Author: Fabien Potencier ([email protected])
Inheritance: implements IteratorAggregate, implements Countable
Exibir arquivo Open project: pmjones/php-framework-benchmarks Class Usage Examples

Protected Properties

Property Type Description
$resources
$routes

Public Methods

Method Description
__clone ( )
__construct ( ) Constructor.
add ( string $name, Symfony\Component\Routing\Route $route ) Adds a route.
addCollection ( RouteCollection $collection, string $prefix = '' ) Adds a route collection to the current set of routes (at the end of the current set).
addCollection ( RouteCollection $collection, string $prefix = '', array $defaults = [], array $requirements = [], array $options = [] ) Adds a route collection to the current set of routes (at the end of the current set).
addPrefix ( string $prefix ) Adds a prefix to all routes in the current set.
addPrefix ( string $prefix, array $defaults = [], array $requirements = [], array $options = [] ) Adds a prefix to all routes in the current set.
addResource ( Symfony\Component\Config\Resource\ResourceInterface $resource ) Adds a resource for this collection.
addResource ( Symfony\Component\Routing\Resource\ResourceInterface $resource ) Adds a resource for this collection.
all ( ) : array Returns the array of routes.
count ( ) : integer Gets the number of Routes in this collection.
get ( string $name ) : Symfony\Component\Routing\Route Gets a route by name.
get ( string $name ) : Symfony\Component\Routing\Route | null Gets a route by name defined in this collection or its children.
getIterator ( ) : ArrayIterator Gets the current RouteCollection as an Iterator that includes all routes and child route collections.
getParent ( ) : RouteCollection | null Gets the parent RouteCollection.
getPrefix ( ) : string Returns the prefix that may contain placeholders.
getResources ( ) : Symfony\Component\Config\Resource\ResourceInterface[] Returns an array of resources loaded to build this collection.
getResources ( ) : Symfony\Component\Routing\Resource\ResourceInterface[] Returns an array of resources loaded to build this collection.
getRoot ( ) : RouteCollection Gets the root RouteCollection of the tree.
remove ( string | array $name ) Removes a route or an array of routes by name from all connected collections (this instance and all parents and children).

Private Methods

Method Description
hasCollection ( RouteCollection $collection ) : boolean Checks whether the given RouteCollection is already set in any child of the current instance.
removeRecursively ( string $name ) : boolean Removes a route by name from this collection and its children recursively.
setParent ( RouteCollection $parent ) Sets the parent RouteCollection. It's only used internally from one RouteCollection to another. It makes no sense to be available as part of the public API.

Method Details

__clone() public method

public __clone ( )

__construct() public method

Constructor.
public __construct ( )

add() public method

Adds a route.
public add ( string $name, Symfony\Component\Routing\Route $route )
$name string The route name
$route Symfony\Component\Routing\Route A Route instance

addCollection() public method

Adds a route collection to the current set of routes (at the end of the current set).
public addCollection ( RouteCollection $collection, string $prefix = '' )
$collection RouteCollection A RouteCollection instance
$prefix string An optional prefix to add before each pattern of the route collection

addCollection() public method

Adds a route collection to the current set of routes (at the end of the current set).
public addCollection ( RouteCollection $collection, string $prefix = '', array $defaults = [], array $requirements = [], array $options = [] )
$collection RouteCollection A RouteCollection instance
$prefix string An optional prefix to add before each pattern of the route collection
$defaults array An array of default values
$requirements array An array of requirements
$options array An array of options

addPrefix() public method

Adds a prefix to all routes in the current set.
public addPrefix ( string $prefix )
$prefix string An optional prefix to add before each pattern of the route collection

addPrefix() public method

Adds a prefix to all routes in the current set.
public addPrefix ( string $prefix, array $defaults = [], array $requirements = [], array $options = [] )
$prefix string An optional prefix to add before each pattern of the route collection
$defaults array An array of default values
$requirements array An array of requirements
$options array An array of options

addResource() public method

Adds a resource for this collection.
public addResource ( Symfony\Component\Config\Resource\ResourceInterface $resource )
$resource Symfony\Component\Config\Resource\ResourceInterface A resource instance

addResource() public method

Adds a resource for this collection.
public addResource ( Symfony\Component\Routing\Resource\ResourceInterface $resource )
$resource Symfony\Component\Routing\Resource\ResourceInterface A resource instance

all() public method

Returns the array of routes.
public all ( ) : array
return array An array of routes

count() public method

Gets the number of Routes in this collection.
public count ( ) : integer
return integer The number of routes in this collection, including nested collections

get() public method

Gets a route by name.
public get ( string $name ) : Symfony\Component\Routing\Route
$name string The route name
return Symfony\Component\Routing\Route $route A Route instance

get() public method

Gets a route by name defined in this collection or its children.
public get ( string $name ) : Symfony\Component\Routing\Route | null
$name string The route name
return Symfony\Component\Routing\Route | null A Route instance or null when not found

getIterator() public method

Gets the current RouteCollection as an Iterator that includes all routes and child route collections.
public getIterator ( ) : ArrayIterator
return ArrayIterator An \ArrayIterator interface

getParent() public method

Gets the parent RouteCollection.
public getParent ( ) : RouteCollection | null
return RouteCollection | null The parent RouteCollection or null when it's the root

getPrefix() public method

Returns the prefix that may contain placeholders.
public getPrefix ( ) : string
return string The prefix

getResources() public method

Returns an array of resources loaded to build this collection.
public getResources ( ) : Symfony\Component\Config\Resource\ResourceInterface[]
return Symfony\Component\Config\Resource\ResourceInterface[] An array of resources

getResources() public method

Returns an array of resources loaded to build this collection.
public getResources ( ) : Symfony\Component\Routing\Resource\ResourceInterface[]
return Symfony\Component\Routing\Resource\ResourceInterface[] An array of resources

getRoot() public method

Gets the root RouteCollection of the tree.
public getRoot ( ) : RouteCollection
return RouteCollection The root RouteCollection

remove() public method

Removes a route or an array of routes by name from all connected collections (this instance and all parents and children).
public remove ( string | array $name )
$name string | array The route name or an array of route names

Property Details

$resources protected_oe property

protected $resources

$routes protected_oe property

protected $routes