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

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

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)訪問(wèn) Index/test 的時(shí)候,并未執(zhí)行 Common 中的 redirect,執(zhí)行了Index中的test方法。

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

求解決方案。

1175 2 0
2個(gè)回答

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

    還是無(wú)效,并沒(méi)有阻止后面的輸出

  • roczyl 2022-08-10

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

  • ichynul 2022-08-10

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

  • roczyl 2022-08-10

    搞定了,非常感謝。

2548a

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

  • roczyl 2022-08-10

    嗯。明白了,第一次接觸,很多思維要改過(guò)來(lái)。

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