Overview

Namespaces

  • Evenement
  • None
  • PHP
  • Psr
    • Http
      • Message
  • Ratchet
    • Http
    • RFC6455
      • Handshake
      • Messaging
    • Server
    • Session
      • Serialize
      • Storage
        • Proxy
    • Wamp
    • WebSocket
  • React
    • EventLoop
      • Tick
      • Timer
    • Socket
    • Stream
  • Symfony
    • Component
      • HttpFoundation
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
      • Routing
        • Annotation
        • Exception
        • Generator
          • Dumper
        • Loader
          • DependencyInjection
        • Matcher
          • Dumper
        • Tests
          • Annotation
          • Fixtures
            • AnnotatedClasses
            • OtherAnnotatedClasses
          • Generator
            • Dumper
          • Loader
          • Matcher
            • Dumper

Classes

  • CompiledRoute
  • RequestContext
  • Route
  • RouteCollection
  • RouteCollectionBuilder
  • RouteCompiler
  • Router

Interfaces

  • RequestContextAwareInterface
  • RouteCompilerInterface
  • RouterInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class RouteCollection

A RouteCollection represents a set of Route instances.

When adding a route at the end of the collection, an existing route with the same name is removed first. So there can only be one route with a given name.

Symfony\Component\Routing\RouteCollection implements IteratorAggregate, Countable
Namespace: Symfony\Component\Routing
Author: Fabien Potencier <fabien@symfony.com>
Author: Tobias Schultze <http://tobion.de>
Located at RouteCollection.php
Methods summary
public
# __clone( )
public ArrayIterator|Symfony\Component\Routing\Route[]
# getIterator( )

Gets the current RouteCollection as an Iterator that includes all routes.

Gets the current RouteCollection as an Iterator that includes all routes.

It implements \IteratorAggregate.

Returns

ArrayIterator|Symfony\Component\Routing\Route[]
An \ArrayIterator object for iterating over routes

See

Symfony\Component\Routing\RouteCollection::all()

Implementation of

IteratorAggregate::getIterator()
public integer
# count( )

Gets the number of Routes in this collection.

Gets the number of Routes in this collection.

Returns

integer
The number of routes

Implementation of

Countable::count()
public
# add( string $name, Symfony\Component\Routing\Route $route )

Adds a route.

Adds a route.

Parameters

$name
string
$name The route name
$route
Symfony\Component\Routing\Route
$route A Route instance
public Symfony\Component\Routing\Route[]
# all( )

Returns all routes in this collection.

Returns all routes in this collection.

Returns

Symfony\Component\Routing\Route[]
An array of routes
public Symfony\Component\Routing\Route|null
# get( string $name )

Gets a route by name.

Gets a route by name.

Parameters

$name
string
$name The route name

Returns

Symfony\Component\Routing\Route|null
A Route instance or null when not found
public
# remove( string|array $name )

Removes a route or an array of routes by name from the collection.

Removes a route or an array of routes by name from the collection.

Parameters

$name
string|array
$name The route name or an array of route names
public
# addCollection( Symfony\Component\Routing\RouteCollection $collection )

Adds a route collection at the end of the current set by appending all routes of the added collection.

Adds a route collection at the end of the current set by appending all routes of the added collection.

Parameters

$collection
Symfony\Component\Routing\RouteCollection
$collection A RouteCollection instance
public
# addPrefix( string $prefix, array $defaults = array(), array $requirements = array() )

Adds a prefix to the path of all child routes.

Adds a prefix to the path of all child routes.

Parameters

$prefix
string
$prefix An optional prefix to add before each pattern of the route collection
$defaults
array
$defaults An array of default values
$requirements
array
$requirements An array of requirements
public
# setHost( string $pattern, array $defaults = array(), array $requirements = array() )

Sets the host pattern on all routes.

Sets the host pattern on all routes.

Parameters

$pattern
string
$pattern The pattern
$defaults
array
$defaults An array of default values
$requirements
array
$requirements An array of requirements
public
# setCondition( string $condition )

Sets a condition on all routes.

Sets a condition on all routes.

Existing conditions will be overridden.

Parameters

$condition
string
$condition The condition
public
# addDefaults( array $defaults )

Adds defaults to all routes.

Adds defaults to all routes.

An existing default value under the same name in a route will be overridden.

Parameters

$defaults
array
$defaults An array of default values
public
# addRequirements( array $requirements )

Adds requirements to all routes.

Adds requirements to all routes.

An existing requirement under the same name in a route will be overridden.

Parameters

$requirements
array
$requirements An array of requirements
public
# addOptions( array $options )

Adds options to all routes.

Adds options to all routes.

An existing option value under the same name in a route will be overridden.

Parameters

$options
array
$options An array of options
public
# setSchemes( string|array $schemes )

Sets the schemes (e.g. 'https') all child routes are restricted to.

Sets the schemes (e.g. 'https') all child routes are restricted to.

Parameters

$schemes
string|array
$schemes The scheme or an array of schemes
public
# setMethods( string|array $methods )

Sets the HTTP methods (e.g. 'POST') all child routes are restricted to.

Sets the HTTP methods (e.g. 'POST') all child routes are restricted to.

Parameters

$methods
string|array
$methods The method or an array of methods
public Symfony\Component\Config\Resource\ResourceInterface
# getResources( )

Returns an array of resources loaded to build this collection.

Returns an array of resources loaded to build this collection.

Returns

Symfony\Component\Config\Resource\ResourceInterface
An array of resources
public
# addResource( Symfony\Component\Config\Resource\ResourceInterface $resource )

Adds a resource for this collection.

Adds a resource for this collection.

Parameters

$resource
Symfony\Component\Config\Resource\ResourceInterface
$resource A resource instance
Ratchet API documentation generated by ApiGen 2.8.0