获取有关在Fat Free v3中执行的路由的信息 [英] Get information about the route executed in Fat Free v3

查看:185
本文介绍了获取有关在Fat Free v3中执行的路由的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Fat Free Framework中的 beforeRoute 方法中根据当前URL执行哪个路由。

I'd like to know which route is executed according to current URL in the beforeRoute method in the Fat Free Framework.

换句话说,我可以获取将要执行的类和方法吗?我在PATTERN变量中获得了有关模式(URL)的信息,但我不知道要为该PATTERN执行哪种类和方法,就像在route.ini中映射的那样。

In other words, can I get which class and which method will be executed? I had info about about the pattern (URL) in PATTERN variable but I don't know which class and method is going to be executed for this PATTERN as mapped in routes.ini.

routes.ini的示例:

Example of my routes.ini:

GET /admin=Controllers\Admin\Admin->index

在这种情况下,我想发现该类是 Controllers\ Admin\Admin ,方法是索引。

In this case I'd like to find that the class is Controllers\Admin\Admin and the method is index.

我已经找到了获取该类的方法:

I've found how to get the class:

get_class($this)

但是我还没有找到如何获取方法名称。请记住,我必须从 beforeRoute 方法中获取方法名称。

But I haven't found how to get the method name. Please remember that I have to get the method name from the beforeRoute method.

推荐答案

我觉得这里是解决方案,它可能会对某些人有所帮助。

i've foud it here is the solution, it may help some one.

要获取将在路由中执行的方法名称:

To get the method name that will be executed in the route :

$hive = $f3->hive();
$tmp = explode('->',$hive['ROUTES'][$f3->get('PATTERN')][3][$hive['VERB']][0]);

因此$ tmp [0]将包含类名,而
$ tmp [1]将包含方法名称。

So $tmp[0] will contain the class name and $tmp[1] will containt de method name.

这篇关于获取有关在Fat Free v3中执行的路由的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆