-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathModule.php
89 lines (78 loc) · 3.3 KB
/
Module.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
namespace nkostadinov\user;
use nkostadinov\user\commands\UserController;
use yii\base\BootstrapInterface;
use yii\i18n\PhpMessageSource;
class Module extends \yii\base\Module implements BootstrapInterface
{
const I18N_CATEGORY = 'nkostadinov.user';
public $controllerNamespace = 'nkostadinov\user\controllers';
/** @var array The rules to be used in URL management. */
public static $urlRules = [
'<action:(login|logout)>' => 'user/security/<action>',
'<action:(signup|resend)>' => 'user/registration/<action>',
'confirm/<code:[\w-]+>' => 'user/registration/confirm',
'forgotten-password' => 'user/recovery/request',
'reset/<code:[\w-]+>' => 'user/recovery/reset',
'change-password' => 'user/security/change-password',
'acquire-email' => 'user/security/acquire-email',
'acquire-password' => 'user/security/acquire-password',
'profile' => 'user/profile/view',
];
/**
* @var bool Whether to register URL rules for this module (defined in static var $urlRules)
*/
public $registerUrls = true;
/**
* @var bool Whether to allow new user to register.
*/
public $allowRegistration = true;
/**
* @var bool Whether to allow new user to register.
*/
public $allowPasswordRecovery = true;
public $registerView = '@nkostadinov/user/views/registration/signup';
public $loginView = '@nkostadinov/user/views/security/login';
public $confirmView = '@nkostadinov/user/views/registration/confirm';
public $requestView = '@nkostadinov/user/views/recovery/request';
public $profileView = '@nkostadinov/user/views/profile/view';
public $changePasswordView = '@nkostadinov/user/views/security/change_password';
public $acquireEmailView = '@nkostadinov/user/views/security/acquire_email';
public $acquirePasswordView = '@nkostadinov/user/views/security/acquire_password';
public $resetPasswordView = '@nkostadinov/user/views/recovery/reset';
public $adminColumns = [
//['class' => 'yii\grid\SerialColumn'],
'displayName',
'email:email',
'statusName',
'created_at:datetime',
'confirmed_on:datetime',
'lastLoginText:html:Last login',
// 'last_login:datetime',
// 'last_login_ip:text',
'register_ip:text',
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Actions',
],
];
public function bootstrap($app)
{
if ($app instanceof \yii\console\Application) {
if(!isset($app->controllerMap[$this->id]))
$app->controllerMap[$this->id] = [
'class' => UserController::className(),
];
} else if ($app instanceof \yii\web\Application) {
$module = $app->getModule('user');
if(($module instanceof self) && $module->registerUrls)
$app->urlManager->addRules(self::$urlRules);
}
if (!isset($app->get('i18n')->translations[self::I18N_CATEGORY])) {
$app->get('i18n')->translations[self::I18N_CATEGORY] = [
'class' => PhpMessageSource::className(),
'basePath' => __DIR__ . '/messages',
];
}
}
}