YII2 where does the code for Beforelogin in this class execute when the User.php class comes with the framework? Need to write for yourself?

Source: Internet
Author: User


This has triggered ...
Where is the code executed after the specific trigger

Reply content:


This has triggered ...
Where is the code executed after the specific trigger

If you do not User::EVENT_BEFORE_LOGIN mount the handler, it will not be triggered.

Update

Use Case 1

Yii::$app->getUser()->on(User::EVENT_AFTER_LGOIN, function($event){ va_dump($event);});....Yii::$app->getUser()->login($user);

Use Case 2

use yii\base\Event;use yii\web\User;Event::on(User::className(), User::EVENT_AFTER_LOGIN, function($event) {    var_dump($event);});

Specific reference documents: Https://github.com/yiisoft/yii2/blob/master/docs/guide/concept-events ....

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.