本文整理汇总了PHP中yii\base\Module::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::init方法的具体用法?PHP Module::init怎么用?PHP Module::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Module
的用法示例。
在下文中一共展示了Module::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
if (!\Yii::$app->user->can('adminDashboard')) {
throw new ForbiddenHttpException('Access denied');
}
}
示例2: init
public function init()
{
parent::init();
/*if ($app instanceof \yii\console\Application) {
$$this->controllerNamespace;
}*/
}
示例3: init
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
{
if (\Yii::$app->authManager === null) {
throw new InvalidConfigException('You forgot configure the "authManager" component.');
}
parent::init();
}
示例4: init
public function init()
{
// Menu backend
$this->backendMenu = [['label' => Yii::t('message', 'Message'), 'url' => ['/message/default'], 'access' => ['message/backend/default/*', 'message/backend/default/index']], ['label' => Yii::t('common', 'Setting'), 'url' => ['/common/setting', 'module' => 'message'], 'access' => ['common/setting']]];
parent::init();
// custom initialization code goes here
}
示例5: init
public function init()
{
parent::init();
if (\Yii::$app instanceof \yii\console\Application) {
$this->controllerNamespace = 'common\\modules\\rbac\\commands';
}
}
示例6: init
public function init()
{
parent::init();
if (is_null($this->attribute)) {
throw new Exception("Module \"attribute\" attribute must be set");
}
if (is_null($this->latitudeAttribute)) {
throw new Exception("Module \"latitudeAttribute\" attribute must be set");
}
if (is_null($this->longitudeAttribute)) {
throw new Exception("Module \"longitudeAttribute\" attribute must be set");
}
if (is_null($this->jsonAttribute)) {
throw new Exception("Module \"jsonAttribute\" attribute must be set");
}
if (is_null($this->class)) {
$this->class = __NAMESPACE__ . '\\models\\Locations';
}
$location = new $this->class();
$location->setAttributes(['destinationAttribute' => $this->attribute, 'latitudeAttribute' => $this->latitudeAttribute, 'longitudeAttribute' => $this->longitudeAttribute, 'jsonAttribute' => $this->jsonAttribute]);
$this->location = $location;
Event::on(Locations::className(), Locations::EVENT_ADD_LOCATION, [Locations::className(), 'addLocation']);
Event::on(Locations::className(), Locations::EVENT_GET_LOCATION, [Locations::className(), 'getLocation']);
return true;
}
示例7: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$handler = new \yii\web\ErrorHandler(['errorAction' => 'empresas/default/error', 'errorView' => '@app/modules/empresas/views/default/error.php']);
Yii::$app->set('errorHandler', $handler);
$handler->register();
}
示例8: init
public function init()
{
parent::init();
// \Yii::$app->request->setAcceptableContentTypes(['application/json' => ['q' => 1]]);
\Yii::$app->user->enableSession = false;
Helper::handle_response();
}
示例9: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->userIdentityClass === null) {
$this->userIdentityClass = \Yii::$app->getUser()->identityClass;
}
}
示例10: init
public function init()
{
parent::init();
// if (Yii::$app instanceof ConsoleApplication) {
// $this->controllerNamespace = 'app\modules\settings\commands';
// }
}
示例11: init
/**
*
*/
public function init()
{
$modulePathAlias = '@app/modules/' . $this->id;
parent::init();
$this->controllerNamespace = 'app\\modules\\' . $this->id . '\\controllers';
Yii::$app->getI18n()->translations[$this->id . '*'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => $modulePathAlias . '/messages'];
}
示例12: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!isset(Yii::$app->i18n->translations['forum'])) {
Yii::$app->i18n->translations['forum'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'ru', 'basePath' => '@terabyte/forum/messages'];
}
}
示例13: init
/**
* @inheritdoc
*/
public function init()
{
if (is_callable($this->userId)) {
$this->userId = call_user_func($this->userId);
}
parent::init();
}
示例14: init
public function init()
{
parent::init();
Yii::$app->user->loginUrl = ['admin/login'];
Yii::$app->user->identityClass = 'app\\modules\\admin\\identity\\Admin';
Yii::configure($this, $this->config());
}
示例15: init
public function init()
{
parent::init();
if (empty($this->reportSettings)) {
throw new Exception('Empty reportSettings');
}
}