我有活动的订阅者
'Shopware_Modules_Admin_SaveRegister_Successful'在某些操作之后,我想在最后执行重定向,但是$args对象没有主题,这意味着我不能在它上面调用$controller = $args->getSubject();并执行重定向。
是否有其他方法可以在此事件的回调函数中执行重定向?'Shopware_Modules_Admin_SaveRegister_Successful' => 'onRegisterSuccessful'
public function onRegisterSuccessful($args){
$controller = $args->getSubject();
$controller->redirect(
array(
'controller' => 'profile',
'action' => 'verify',
'name' => $name
)
);
}发布于 2020-10-08 19:04:26
试着这样做。请注意,您需要在重定向之后退出(),因为在触发事件之后,Shopware将自己重定向到客户仪表板。
public static function getSubscribedEvents()
{
return [
'Shopware_Modules_Admin_SaveRegister_Successful' => 'onregister'
];
}
public function onRegister(\Enlight_Event_EventArgs $args)
{
$url = Shopware()->Front()->Router()->assemble([
'controller' => 'profile',
'action' => 'verify'
]);
header('Location: ' . $url, true);
exit();
}发布于 2020-10-02 13:59:39
您的选择是再高一点,注册一个控制器的postDispatch事件。在那里你可以重定向。
https://stackoverflow.com/questions/64161140
复制相似问题