国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

action-hook插件,beforeAction繼承時出現(xiàn) return response 無效的問題。

roczyl

Common中:
public function beforeAction(Request $request)
{
$config = get_site_config();
$h = date('H', time());
/ 站點(diǎn)關(guān)閉公告 /
if ($config['siteopen'] == 0) {
return redirect('/index/base/closed');
}
}

Index中:
class Index extends Common
public function beforeAction(Request $request)
{
parent::beforeAction($request);
}

public function test(Request $request)
{
return response('I\'m test');
}

發(fā)現(xiàn)當(dāng)訪問 Index/test 的時候,并未執(zhí)行 Common 中的 redirect,執(zhí)行了Index中的test方法。

如果將 return redirect('/index/base/closed') 放到 Index 的beforeAction,卻又能夠執(zhí)行。

求解決方案。

1222 2 0
2個回答

ichynul
$response = parent::beforeAction($request);
if($response)
{
    return $response;
}
  • roczyl 2022-08-10

    還是無效,并沒有阻止后面的輸出

  • roczyl 2022-08-10

    測試了一下,parent::beforeAction($request) 返回的是 NULL

  • ichynul 2022-08-10

    parent::beforeAction不一定有返回,if ($config['siteopen'] == 0) 這個條件成立嗎

  • roczyl 2022-08-10

    搞定了,非常感謝。

2548a

這不就對了嘛,問問題你把東西都貼上來才行呀,不然誰會去回你問題.問題出在index類的 beforeAction 方法上,你僅僅只是調(diào)用了 parent::beforeAction($request); 是沒用的,這個如果有響應(yīng)你是要return 回去才會處理的.

  • roczyl 2022-08-10

    嗯。明白了,第一次接觸,很多思維要改過來。

年代過于久遠(yuǎn),無法發(fā)表回答
??