doutou19761022 2014-06-04 19:23
浏览 87

Laravel:事件监听器通配符未触发

I have an event listener that uses a wild card to listen for any sentinel.user.* event.

Here's the listener:

Event::listen('sentinel.user.*', function ($userID = null){
    error_log('log listener fired');
    $userLog           = new UserLog;
    $EventNameExploded = explode("." , Event::firing());
    $EventNameEnding   = array_pop($EventNameExploded);
    $logAction         = "User " . $EventNameEnding;
    $logData           = array('eventDescription' => $logAction);

    $userLog->submitLog($logData,$userID);
},99);

For some reason this doesn't fire for the sentinel.user.forgot event. It does fire for any other sentinel.user event.

While troubleshooting, I added a listener for the specific sentinel.user.forgot event:

Event::listen('sentinel.user.forgot', function (){
    error_log('forgot listener fired');
}, 98);

This event listener will fire. I even gave it a priority that was lower than the log event and the log event will not fire but the forgot specific one will fire. I have no even listeners with a priority higher than 99 or 98.

Does anyone know why the listener isn't firing???

EDIT:

Here's the code that fires the sentinel.user.forgot event:

public function forgot()
{
    // Form Processing
    $result = $this->forgotPasswordForm->forgot( Input::all() );

    if( $result['success'] )
    {
        Event::fire('sentinel.user.forgot', array(
            'email'     => $result['mailData']['email'],
            'userId'    => $result['mailData']['userId'],
            'resetCode' => $result['mailData']['resetCode']
        ));

        // Success!
        Session::flash('success', $result['message']);
        return Redirect::route('home');
    } 
    else 
    {
        Session::flash('error', $result['message']);
        return Redirect::route('Sentinel\forgotPasswordForm')
            ->withInput()
            ->withErrors( $this->forgotPasswordForm->errors() );
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line