Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

route结构 #204

Open
sunmenghua opened this issue Oct 28, 2015 · 1 comment
Open

route结构 #204

sunmenghua opened this issue Oct 28, 2015 · 1 comment

Comments

@sunmenghua
Copy link

我的想法是这样的:在定义路由的时候添加一些其它额外的属性,然后在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 )来配置路由了。

@letwang
Copy link

letwang commented Jun 12, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants