Yet Another Framework Yaf_Router::addConfig

(Yaf >=1.0.0)

Yaf_Router::addConfig — 라우터에 구성 정의 경로 추가


설명

public Yaf_Router::addConfig(Yaf_Config_Abstract $config): bool

구성에서 정의한 경로를 Yaf_Router의 경로 스택에 추가


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

하나 이상의 유효한 경로 구성을 포함해야 하는 Yaf_Config_Abstract 인스턴스


Examples

예제 #1 application.ini() 예제

;the order is very important, the prior one will be called first

;a rewrite route match request /product/*/*
routes.route_name.type="rewrite"
routes.route_name.match="/product/:name/:value"
routes.route_name.route.controller=product
routes.route_name.route.action=info

;a regex route match request /list/*/*
routes.route_name1.type="regex"
routes.route_name1.match="#^list/([^/]*)/([^/]*)#"
routes.route_name1.route.controller=Index
routes.route_name1.route.action=action
routes.route_name1.map.1=name
routes.route_name1.map.2=value

;a simple route match /**?c=controller&a=action&m=module
routes.route_name2.type="simple"
routes.route_name2.controller=c
routes.route_name2.module=m
routes.route_name2.action=a

;a simple router match /**?r=PATH_INFO
routes.route_name3.type="supervar"
routes.route_name3.varname=r

;a map route match any request to controller
routes.route_name4.type="map"
routes.route_name4.controllerPrefer=TRUE
routes.route_namer.delimiter="#!"
                

예제 #2 Yaf_Dispatcher::autoConfig() 예제

                  
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract{
    public function _initConfig() {
        $config = Yaf_Application::app()->getConfig();
        Yaf_Registry::set("config", $config);
    }

    public function _initRoute(Yaf_Dispatcher $dispatcher) {
        $router = $dispatcher->getRouter();
        /**
         * we can add some pre-defined routes in application.ini
         */
        $router->addConfig(Yaf_Registry::get("config")->routes);
    }
?>
                  
                

기타