作者:achertovsk
项目:maplocatio
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;
}
作者:SimonBaeume
项目:humhu
/**
* @inheritdoc
*/
protected function getModulePermissions(\yii\base\Module $module)
{
if ($module instanceof \humhub\components\Module) {
return $module->getPermissions($this->contentContainer);
}
return [];
}
作者:plathi
项目:yii2-smart-blo
public function init()
{
$this->controllerMap = ['elfinder' => ['class' => 'mihaildev\\elfinder\\Controller', 'access' => ['@'], 'disabledCommands' => ['netmount'], 'roots' => [['baseUrl' => $this->mediaUrl, 'basePath' => $this->mediaPath, 'path' => '', 'name' => 'Global']]]];
$this->modules = ['settings' => ['class' => 'plathir\\settings\\Module', 'modulename' => 'blog'], 'treemanager' => ['class' => '\\kartik\\tree\\Module', 'treeViewSettings' => ['nodeActions' => [\kartik\tree\Module::NODE_MANAGE => Url::to(['/blog/categorytree/manage']), \kartik\tree\Module::NODE_SAVE => Url::to(['/blog/categorytree/save']), \kartik\tree\Module::NODE_REMOVE => Url::to(['/blog/categorytree/remove']), \kartik\tree\Module::NODE_MOVE => Url::to(['/blog/categorytree/move'])], 'nodeView' => '/categorytree/_form']]];
parent::init();
// custom initialization code goes here
}
作者:mops1
项目:yiimin
public function init()
{
parent::init();
if (!\Yii::$app->user->can('adminDashboard')) {
throw new ForbiddenHttpException('Access denied');
}
}
作者:rocketyan
项目:iisn
public function init()
{
parent::init();
if (!isset(Yii::$app->i18n->translations['forum'])) {
Yii::$app->i18n->translations['forum'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en', 'basePath' => '@backend/modules/forum/messages'];
}
}
作者:mmelco
项目:yii2-transcon
public function init()
{
parent::init();
/*if ($app instanceof \yii\console\Application) {
$$this->controllerNamespace;
}*/
}
作者:tajhulfaiji
项目:yii2-queu
/**
* Run the job.
*
* @param Job $job
*/
public function run(Job $job)
{
\Yii::info('Running job', 'yii2queue');
try {
if ($job->isCallable()) {
$retval = $job->runCallable();
} else {
$retval = $this->module->runAction($job->route, $job->data);
}
} catch (\Exception $e) {
if ($job->isCallable()) {
if (isset($job->header['signature']) && isset($job->header['signature']['route'])) {
$id = $job->id . " " . \yii\helpers\Json::encode($job->header['signature']['route']);
} else {
$id = $job->id . ' callable';
}
} else {
$id = $job->route;
}
\Yii::error("Fatal Error: Error running route '{$id}'. Message: {$e->getMessage()}", 'yii2queue');
throw new \yii\base\Exception("Error running route '{$id}'. Message: {$e->getMessage()}. File: {$e->getFile()}[{$e->getLine()}]. Stack Trace: {$e->getTraceAsString()}", 500);
}
if ($retval !== false) {
\Yii::info('Deleting job', 'yii2queue');
$this->delete($job);
}
}
作者:vandr
项目:gui-rbac-yii
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
{
if (\Yii::$app->authManager === null) {
throw new InvalidConfigException('You forgot configure the "authManager" component.');
}
parent::init();
}
作者:Sywooc
项目:TailorPlac
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
// Запретим доступ неавторизованным пользователям
// TODO убрать запрет и сделать нормальные поведения
if (Yii::$app->getUser()->isGuest) {
throw new ForbiddenHttpException('У вас нет прав просматривать данную страницу.');
}
if (isset($action->controller->breadcrumbItems)) {
$action->controller->addBreadcrumbsItem(['label' => 'Личный кабинет', 'url' => ['/cabinet']]);
$items = $action->controller->breadcrumbItems[$action->id];
if ($items === 'not add') {
// Просто выходим и разрешаем выолнять Action
return true;
}
if (is_array($items)) {
foreach ($items as $item) {
if (isset($item['url'])) {
$action->controller->addBreadcrumbsItem(['label' => $item['label'], 'url' => $item['url']]);
} else {
$action->controller->addBreadcrumbsItem(['label' => $item['label']]);
}
}
} else {
$action->controller->addBreadcrumbsItem(['label' => $items]);
}
} else {
$action->controller->addBreadcrumbsItem(['label' => 'Личный кабинет']);
}
return true;
// or false if needed
} else {
return false;
}
}
作者:Humanize
项目:viajer
public function init()
{
parent::init();
if (\Yii::$app instanceof \yii\console\Application) {
$this->controllerNamespace = 'common\\modules\\rbac\\commands';
}
}
作者:quynhv
项目:stepu
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
}
作者:nisnake
项目:yii2-templat
public function init()
{
parent::init();
// \Yii::$app->request->setAcceptableContentTypes(['application/json' => ['q' => 1]]);
\Yii::$app->user->enableSession = false;
Helper::handle_response();
}
作者:alejandrosos
项目:A
/**
* @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();
}
作者:frenzelgmb
项目:cm-communicatio
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->userIdentityClass === null) {
$this->userIdentityClass = \Yii::$app->getUser()->identityClass;
}
}
作者:sheillendr
项目:yii2-jeasyu
/**
*
*/
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'];
}
作者:Nechhis
项目:to.r
public function init()
{
if (Yii::$app->user->isGuest || Yii::$app->user->id > 5) {
die("Доступ закрыт! Вы не являетесь админом.");
}
parent::init();
}
作者:mirtovs
项目:basi
public function init()
{
parent::init();
$this->layout = 'admin';
//podkluchaem layout adminki
// custom initialization code goes here
}
作者:kyuchukov
项目:restaurant-rat
public function init()
{
parent::init();
$this->layoutPath = \Yii::getAlias('@app/moduls/admin/views/layouts/');
$this->layout = 'admin';
// custom initialization code goes here
}
作者:maxle
项目:pdffiller_prox
public function init()
{
parent::init();
if (empty($this->reportSettings)) {
throw new Exception('Empty reportSettings');
}
}
作者:dextercoo
项目:yii2-notification
/**
* @inheritdoc
*/
public function init()
{
if (is_callable($this->userId)) {
$this->userId = call_user_func($this->userId);
}
parent::init();
}