Graph-IT

Router.php

Looking at the 'Router.php' from giwt, there are a bunch of public functions to take note of.

__constructor

__construct(Kernel $kernel = null)

In case a Kernel instance is passed to the constructor the routes saved under $kernel['config']['routes'] will initialize the protected $routes array of the Router-class which represents a list of all known routes (see: 'route config' below).

addRoutes

public function addRoutes($routes)

This function takes an array of routes and adds them to the known routes. In case the array contains an already known route an 'Exception` will be thrown.

getRoute

public function getRoute($name)

Given the name of a route, this function will return a new Route-instance. In case the name doesn't match to any known route an 'Exception` will be thrown.

match

public function match(Request $request)

This function takes a Request as input and returns all the data belonging to the first route which matches the request path. The data for a route is an array with the following entries:

build

public function build(Request $request, $name, array $variables = array(), $absolute = false, array $query = array())

This method builds and returns an url for the given parameters.

route config

Here's a small roundup of what defines a route in giwt..

public function __construct($name, $pattern, array $defaults = array(), array $requirements = array())

The constuctor of Graphit\Core\Route shows there are two required arguments and two optional.