/** * Initial application compoments and modules need for extension * @param \yii\base\Application $app The application currently running * @return void */ public function bootstrap($app) { if (Yii::$app->hasModule('user')) { // Set alias for extension source Yii::setAlias("@userplus", __DIR__); Yii::setAlias("@suckkay/userplus", __DIR__); // Setup i18n compoment for translate all category user* if (!isset(Yii::$app->get('i18n')->translations['user*'])) { Yii::$app->get('i18n')->translations['user*'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . '/messages']; } if (Helper::isConsoleApplication()) { $module = Yii::$app->getModule('user'); // Mapping command controller foreach ($module->getCommandControllerMap() as $key => $value) { Yii::$app->controllerMap[$key] = ['class' => $value]; } // Don't catch all controller with its namespace $module->controllerNamespace = 'suckkay\\userplus\\fake'; } if (Yii::$app->hasModule('rbac')) { $rbacModule = Yii::$app->getModule('rbac'); if (get_class($rbacModule) === 'suckkay\\rbacplus\\Module') { $rbacModule->beforeCreateController = [$this, 'beforeRbacCreateController']; } } } }
/** * * @return string */ public function generateRecoveryToken() { $token = Helper::generateRandomString($this->userPlusModule->tokenLenght); $this->recovery_token = $token; return $this->recovery_token; }