yaf icon indicating copy to clipboard operation
yaf copied to clipboard

route结构

Open sunmenghua opened this issue 10 years ago • 1 comments

我的想法是这样的:在定义路由的时候添加一些其它额外的属性,然后在plugin中根据这些属性做一些检查操作。

route.ini: user_following.type="rewrite" user_following.match="/:username/following$" user_following.route.module=index user_following.route.controller=user user_following.route.action=following user_following.route.otherParam=test

根据上边的route.ini获取到 Yaf\Dispatcher::getInstance()->getRouter()->getRoute('user_following'):

Yaf\Route\Rewrite Object
(
    [_route:protected] => /:username/following$
    [_default:protected] => Array
        (
            [module] => index
            [controller] => user
            [action] => following
            [otherParam] => test
        )

    [_verify:protected] => Array
        (
            [module] => index
            [controller] => user
            [action] => following
            [otherParam] => test
        )

)

然而"otherParam"也像“m c a”被定义成protected了,所以目前是访问不到的。

所以目前的解决方法只能通过扩展Yaf_Route_Rewrite添加getParam方法,但如果使用这种方法的话就不能使用Yaf_Config::addConfig( Yaf_Config_Abstract $routes_config )来配置路由了。

sunmenghua avatar Oct 28 '15 06:10 sunmenghua

问题解决了吧?最好使用静态路由

letwang avatar Jun 12 '19 02:06 letwang