• PHP reference
  • Core
  • Controller

Route

class Core\Controller\Route

Class Route.

Methods

__construct(string $route, array $defaults = [], array $reqs = [])

Prepares the route for mapping by splitting (exploding) it to a corresponding atomic parts. These parts are assigned a position which is later used for matching and preparing values.

Parameters

  • string $route Map used to match with later submitted URL path
  • array $defaults Defaults for map variables with keys as variable names
  • array $reqs Regular expression requirements for variables (keys as variable names)

array|false match(string $path)

Matches a user submitted path with parts defined by a map. Assigns and returns an array of variables on a successful match.

Parameters

  • string $path Path used to match against this routing map

Return Value

  • array|false An array of assigned values or a false on a mismatch

string assemble(array $data = [], boolean $reset = false)

Assembles user submitted parameters forming a URL path defined by this route.

Parameters

  • array $data An array of variable and value pairs used as parameters
  • boolean $reset Whether or not to set route defaults with those provided in $data

Return Value

  • string Route path with user submitted parameters

Exceptions

string getDefault(string $name)

Return a single parameter of route's defaults.

Parameters

  • string $name Array key of the parameter

Return Value

  • string Previously set default

array getDefaults()

Return an array of defaults.

Return Value

  • array Route defaults