diff --git a/docs/events/form-events.md b/docs/events/form-events.md index e69de29..5c108b1 100644 --- a/docs/events/form-events.md +++ b/docs/events/form-events.md @@ -0,0 +1,86 @@ +Form Events +=========== + +The following is the list of the form events and where they happen: + +On Controllers +-------------- + +- **RecoveryController** + - **FormEvent::EVENT_BEFORE_REQUEST**: Occurs before a password recovery request + - **FormEvent::EVENT_AFTER_REQUEST**: Occurs after a password recovery request + + +- **RegistrationController** + - **FormEvent::EVENT_BEFORE_RESEND**: Occurs before a confirmation message is being sent via email + - **FormEvent::EVENT_AFTER_RESEND**: Occurs after a confirmation message is being sent via email + + +- **SecurityController** + - **FormEvent::EVENT_BEFORE_LOGIN**: Occurs before a user logs into the system + - **FormEvent::EVENT_AFTER_LOGIN**: Occurs after a user logs into the system + +How to Work With Form Events +---------------------------- + +All these events received an instance of a `Da\User\Event\FormEvent`. The event receives an instance of a form +depending on where its being called. The following is the list of the forms accessible via `FormEvent::getForm()`: + +- **FormEvent::EVENT_BEFORE_LOGIN|EVENT_AFTER_LOGIN**: It will contain a `Da\User\Form\LoginForm` instance with the + submitted data +- **FormEvent::EVENT_BEFORE_RESEND|EVENT_AFTER_RESEND**: It will contain a `Da\User\Form\ResendForm` instance with the + submitted data +- **FormEvent::EVENT_BEFORE_REQUEST|EVENT_AFTER_REQUEST**: It will contain a `Da\User\Form\RecoveryForm` instance with + the submitted data + +The recommended way to make use of events is by creating a new file in your config folder (i.e. `events.php`), configure +there all your events and then include that file on your +[`entry script`](http://www.yiiframework.com/doc-2.0/guide-structure-entry-scripts.html). + +Here is an example of setting an event for the `RecoveryController`: + +```php +getForm(); + + // ... your logic here +} + +``` + +Now, include `events.php` file to your entry script (i.e. `index.php`). The following is taken from the Yii 2 Advanced +Application Template: + +```php +run(); + +``` + +© [2amigos](http://www.2amigos.us/) 2013-2017 + diff --git a/docs/events/user-events.md b/docs/events/user-events.md index cc51fb4..b0c9220 100644 --- a/docs/events/user-events.md +++ b/docs/events/user-events.md @@ -17,20 +17,20 @@ On Controllers - **UserEvent::EVENT_AFTER_BLOCK**: Occurs after a user is being blocked (forbid access to app) - **UserEvent::EVENT_BEFORE_UNBLOCK**: Occurs before a user is being un-blocked - **UserEvent::EVENT_AFTER_UNBLOCK**: Occurs after a user is being un-blocked - - + + - **RegistrationController** - **UserEvent::EVENT_BEFORE_REGISTER**: Occurs before user registration - **UserEvent::EVENT_AFTER_REGISTER**: Occurs after user registration - **UserEvent::EVENT_BEFORE_CONFIRMATION** - **UserEvent::EVENT_AFTER_CONFIRMATION** - - + + - **SecurityController** - **UserEvent::EVENT_BEFORE_LOGOUT**: Occurs before user logs out of the app - **UserEvent::EVENT_AFTER_LOGOUT**: Occurs after user logs out of the app - - + + - **SettingsController** - **UserEvent::EVENT_BEFORE_PROFILE_UPDATE** - **UserEvent::EVENT_AFTER_PROFILE_UPDATE** @@ -38,7 +38,7 @@ On Controllers - **UserEvent::EVENT_AFTER_ACCOUNT_UPDATE**: Occurs after the user account is updated - **UserEvent::EVENT_BEFORE_DELETE**: Occurs before the user account is deleted - **UserEvent::EVENT_AFTER_DELETE**: Occurs after the user account is deleted - + On Models --------- @@ -69,6 +69,7 @@ Here is an example of setting an event for the `AdminController` and the `User` // events.php file use Da\Controller\AdminController; +use Da\Event\UserEvent; use Da\Model\User; use yii\base\Event; diff --git a/src/User/Controller/SecurityController.php b/src/User/Controller/SecurityController.php index c0da973..06e0fbc 100644 --- a/src/User/Controller/SecurityController.php +++ b/src/User/Controller/SecurityController.php @@ -101,7 +101,8 @@ class SecurityController extends Controller /** * Controller action responsible for handling login page and actions. - * @return string|Response + * + * @return array|string|Response */ public function actionLogin() {