symfony API

sfRouting Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

Packages

You are currently browsing the symfony API for the 1.0 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

sfRouting class controls the creation of URLs and parses URLs. It maps an array of parameters to URLs definition.

Method Summary

  • appendRoute()
    Adds a new route.
  • clearRoutes()
    Clears all current routes.
  • array connect(, , , )
    Adds a new route at the end of the current list of routes.
  • string generate(, , )
    Generates a valid URLs for parameters.
  • string getCurrentInternalUri()
    Gets the internal URI for the current request.
  • string getCurrentRouteName()
    Gets the current route name.
  • sfRouting getInstance()
    Retrieve the singleton instance of this class.
  • array getRouteByName()
    Gets a route by its name.
  • array getRoutes()
    Gets the current compiled route array.
  • boolean hasRouteName()
    Returns true if the route name given is defined.
  • boolean hasRoutes()
    Returns true if this instance has some routes.
  • array parse()
    Parses a URL to find a matching route.
  • prependRoute()
    Adds a new route at the beginning of the current list of routes.
  • setCurrentRouteName()
    Sets the current route name.
  • array setRoutes()
    Sets the compiled route array.

Method Details

  • appendRoute ()

    Adds a new route.


    Alias for the connect method.

  • clearRoutes ()

    Clears all current routes.

  • (array) connect (, , , )

    Adds a new route at the end of the current list of routes.


    A route string is a string with 2 special constructions:
    - :string: :string denotes a named paramater (available later as $request->getParameter('string'))
    - *: * match an indefinite number of parameters in a route

    Here is a very common rule in a symfony project:


    $r->connect('/:module/:action/*');

    returns current routes

  • (string) generate (, , )

    Generates a valid URLs for parameters.

    returns The generated URL

  • (string) getCurrentInternalUri ()

    Gets the internal URI for the current request.

    returns The current internal URI

  • (string) getCurrentRouteName ()

    Gets the current route name.

    returns The route name

  • (sfRouting) getInstance ()

    Retrieve the singleton instance of this class.

    returns The sfRouting implementation instance

  • (array) getRouteByName ()

    Gets a route by its name.

    returns A route array

  • (array) getRoutes ()

    Gets the current compiled route array.

    returns The route array

  • (boolean) hasRouteName ()

    Returns true if the route name given is defined.

  • (boolean) hasRoutes ()

    Returns true if this instance has some routes.

  • (array) parse ()

    Parses a URL to find a matching route.


    Returns null if no route match the URL.

    returns An array of parameters

  • prependRoute ()

    Adds a new route at the beginning of the current list of routes.

  • setCurrentRouteName ()

    Sets the current route name.

  • (array) setRoutes ()

    Sets the compiled route array.

    returns The route array