PHP Class Controller_PatternRouter, atk4

in Frontend: $r = $this->add("Controller_PatternRouter") ->addRule("(news\/.*)", "news_item", array("u")) ->route(); if REQUEST_URI is "/news/some-name-of-your-news/", then router would: 1) set $this->app->page to "news_item" 2) set $_GET["u"] to "news/some-name-of-your-news/" uri. Authors: [email protected], [email protected].
Inheritance: extends AbstractController
Show file Open project: atk4/atk4 Class Usage Examples

Public Properties

Property Type Description
$app App_Web

Protected Properties

Property Type Description
$links array
$rules array

Public Methods

Method Description
addRule ( $regex, $target = null, $params = null ) Add new rule to the pattern router. If $regexp is matched, then page is changed to $target and arguments returned by preg_match are stored inside GET as per supplied params array.
buildURL ( $junk, $url )
init ( ) }}}
link ( $page, $args = [] ) Link method creates a bi-directional link between a URL and a page along with some GET parameters. This method is entirely tranpsarent and can be added for pages which are already developed at any time.
route ( ) Perform the necessary changes in the APP's page. After this you can still get the orginal page in app->page_orig.
setModel ( $model ) Allows use of models. Define a model with fields: - rule - target - params (comma separated).
url ( )

Method Details

addRule() public method

Add new rule to the pattern router. If $regexp is matched, then page is changed to $target and arguments returned by preg_match are stored inside GET as per supplied params array.
public addRule ( $regex, $target = null, $params = null )

buildURL() public method

public buildURL ( $junk, $url )

init() public method

}}}
public init ( )

route() public method

Perform the necessary changes in the APP's page. After this you can still get the orginal page in app->page_orig.
public route ( )

setModel() public method

and content of that model will be used to auto-fill routing
public setModel ( $model )

url() public method

public url ( )

Property Details

$app public property

public App_Web $app
return App_Web

$rules protected property

protected array $rules
return array