PHP Asynchronous Method Call In The Yii Framework

后端 未结 3 1164
情深已故
情深已故 2021-02-05 22:57

Question

I want to know if it is possible to asynchronously invoke a Yii controller method from one of its actions while the action renders a view, leaving the method

3条回答
  •  一向
    一向 (楼主)
    2021-02-05 23:27

    Here's an entirely different type of suggestion. What about registering for the onEndRequest event that is fired by CWebApplication's end() function?

    public function end($status=0, $exit=true)
    {
        if($this->hasEventHandler('onEndRequest'))
            $this->onEndRequest(new CEvent($this));
        if($exit)
            exit($status);
    }
    

    You'd need to register for the event and figure out how to pass your model in somehow, but the code would properly run after all the data has been flushed to the browser ...

提交回复
热议问题