PHP Класс 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].
Показать файл
Открыть проект
Примеры использования класса
Открытые свойства
Свойство |
Тип |
Описание |
|
$app |
App_Web |
|
|
Защищенные свойства (Protected)
Открытые методы
Метод |
Описание |
|
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 ( ) |
|
|
Описание методов
addRule()
публичный Метод
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()
публичный Метод
Example:
$this->link('profile',array('user_id'));
public link ( $page, $args = [] ) |
Perform the necessary changes in the APP's page. After this
you can still get the orginal page in app->page_orig.
setModel()
публичный Метод
and content of that model will be used to auto-fill routing
Описание свойств
public App_Web $app |
Результат |
App_Web |
|
$links защищенное свойство
protected array $links |
Результат |
array |
|
$rules защищенное свойство
protected array $rules |
Результат |
array |
|