-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBootstrap.php
43 lines (36 loc) · 1.16 KB
/
Bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace app;
use dektrium\user\controllers\RegistrationController;
use dektrium\user\events\FormEvent;
use yii\base\Application;
use yii\base\BootstrapInterface;
use yii\base\Event;
class Bootstrap implements BootstrapInterface
{
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
$cookies = $app->request->cookies;
$app->language = $cookies->getValue('RH_LANGUAGE','sk');
Event::on(
RegistrationController::className(),
RegistrationController::EVENT_BEFORE_REGISTER,
function (FormEvent $event) use ($app) {
// generating api key
$form = $event->getForm();
$form->api_key = $app->security->generateRandomString(16);
$event->setForm($form);
}
);
Event::on(
RegistrationController::className(),
RegistrationController::EVENT_AFTER_REGISTER,
function ($event) {
// implement role assignment(s)
}
);
}
}