2013-03-28 57 views
2

我今天從SS 3.0升級到3.1,自更新以來,系統似乎沒有在我的extensions的_config文件夾中檢測到我的routes.yml文件。這裏是我的myextension/_config/routes.yml文件的例子:路由升級到3.1後無法工作

--- 
Name: pusherroutes 
After: 
    - '#rootroutes' 
--- 
Director: 
    rules: 
    # handle old 2.4 style urls 
    'pusher/$Action': 'PusherController' 

我也把我的allowed_actions靜態到白名單我的控制器操作:

class PusherController extends Controller { 
    public static $allowed_actions = array (
    'ChatAuth', 
    'SendMessage', 
    'NotifyAuth' 
    ); 
} 

當我瀏覽到mysite.com/推送器/ SendMessage系統不再指引我到控制器上的操作方法。在我的網絡選項卡中返回的響應是Silverstripe入門頁面。

回答

3

這是因爲$Action參數被匹配兩次。當匹配初始pusher/$Action路由時,URL的前兩部分將作爲匹配的一部分使用。控制然後傳遞給您的PusherController對象。然後,它會嘗試再次將URL與動作相匹配,但由於沒有可解析的URL,因此它決定不存在任何動作,因此它會路由到index動作,動作會顯示入門信息。

爲了解決這個問題,只需使用:

Director: 
    rules: 
    'pusher': 'PusherController' 

,並依靠動作匹配時,控制交給PusherController正在做。

相關問題