/** * @inheritdoc */ public function init() { parent::init(); /* @var $dataProvider ActiveDataProvider */ $dataProvider = $this->grid->dataProvider; if (!$dataProvider instanceof ActiveDataProvider) { throw new InvalidConfigException('SortableColumn works only with ActiveDataProvider.'); } if (!$this->gridContainerId) { throw new InvalidConfigException('$gridContainerId property must be set.'); } Yii::setAlias('@sortable', dirname(__DIR__)); Yii::$app->i18n->translations['sortable'] = ['class' => PhpMessageSource::className(), 'basePath' => '@sortable/messages']; /* @var $query \yii\db\ActiveQuery */ $query = $dataProvider->query; $this->_model = new $query->modelClass(); $this->contentOptions = function ($model) { /* @var $model ActiveRecord|BaseNumericalSortableBehavior */ return ['class' => 'sortable-cell', 'data-position' => $model->getSortablePosition()]; }; if (!$this->header) { $this->header = Yii::t('sortable', 'Sort'); } $this->visible = $this->isVisible(); if (!$this->template) { $this->template = '<div class="sortable-section">{currentPosition}</div> <div class="sortable-section">{moveWithDragAndDrop}</div> <div class="sortable-section">{moveForward} {moveBack}</div> <div class="sortable-section">{moveAsFirst} {moveAsLast}</div>'; } $this->initDefaultButtons(); if (!Yii::$app->request->isAjax) { $this->registerJs(); } }
public function bootstrap($app) { if ($app->hasModule('order') && ($module = $app->getModule('order')) instanceof Module) { if ($app instanceof ConsoleApplication) { } else { $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules]; if ($module->urlPrefix != 'order') { $configUrlRule['routePrefix'] = 'order'; } $app->urlManager->addRules([new GroupUrlRule($configUrlRule)], false); } // register auth manager if ($app->authManager === null) { throw new InvalidConfigException('You should configure authManager component'); } if (!$this->checkSettingModuleInstalled($app)) { throw new InvalidConfigException('You should configure pheme\\settings module'); } if (!$this->checkGridViewModuleInstalled($app)) { throw new InvalidConfigException('You should configure kartik\\grid module'); } if (!$this->checkAttachmentsModuleInstalled($app)) { throw new InvalidConfigException('You should configure nemmo\\attachments module'); } // if (!$this->checkUserClassConfigured($app)) { // throw new InvalidConfigException('You should configure your user class instance of ActiveRecord'); // } } if (!isset($app->get('i18n')->translations['order*'])) { $app->get('i18n')->translations['order*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } }
/** @inheritdoc */ public function bootstrap($app) { /** @var $module Module */ if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) { $this->_modelMap = array_merge($this->_modelMap, $module->modelMap); foreach ($this->_modelMap as $name => $definition) { $class = "dektrium\\user\\models\\" . $name; \Yii::$container->set($class, $definition); $modelName = is_array($definition) ? $definition['class'] : $definition; $module->modelMap[$name] = $modelName; if (in_array($name, ['User', 'Profile', 'Token', 'Account'])) { \Yii::$container->set($name . 'Query', function () use($modelName) { return $modelName::find(); }); } } \Yii::$container->setSingleton(Finder::className(), ['userQuery' => \Yii::$container->get('UserQuery'), 'profileQuery' => \Yii::$container->get('ProfileQuery'), 'tokenQuery' => \Yii::$container->get('TokenQuery'), 'accountQuery' => \Yii::$container->get('AccountQuery')]); if ($app instanceof ConsoleApplication) { $module->controllerNamespace = 'dektrium\\user\\commands'; } else { \Yii::$container->set('yii\\web\\User', ['enableAutoLogin' => true, 'loginUrl' => ['/user/security/login'], 'identityClass' => $module->modelMap['User']]); $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules]; if ($module->urlPrefix != 'user') { $configUrlRule['routePrefix'] = 'user'; } $app->get('urlManager')->rules[] = new GroupUrlRule($configUrlRule); if (!$app->has('authClientCollection')) { $app->set('authClientCollection', ['class' => Collection::className()]); } } $app->get('i18n')->translations['user*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; $defaults = ['welcomeSubject' => \Yii::t('user', 'Welcome to {0}', \Yii::$app->name), 'confirmationSubject' => \Yii::t('user', 'Confirm account on {0}', \Yii::$app->name), 'reconfirmationSubject' => \Yii::t('user', 'Confirm email change on {0}', \Yii::$app->name), 'recoverySubject' => \Yii::t('user', 'Complete password reset on {0}', \Yii::$app->name)]; \Yii::$container->set('dektrium\\user\\Mailer', array_merge($defaults, $module->mailer)); } }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { if (!isset($app->get('i18n')->translations['roxy*'])) { $app->get('i18n')->translations['roxy*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US']; } Yii::setAlias('roxymce', __DIR__); }
public function run() { Yii::$app->response->format = Response::FORMAT_JSON; if (Yii::$app->user->isGuest || !Yii::$app->request->isAjax) { throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.')); } if (!$this->model) { throw new InvalidConfigException('The "model" property must be set.'); } if (!$this->keyField) { throw new InvalidConfigException('The "keyField" property must be set.'); } if (!$this->valueField) { throw new InvalidConfigException('The "valueField" property must be set.'); } if ($this->group !== null && ($this->_group_id = Yii::$app->request->post('group_id', null)) === null) { throw new BadRequestHttpException('Bad request'); } Yii::$app->i18n->translations['skinka/ordering/*'] = ['class' => PhpMessageSource::className(), 'basePath' => '@vendor/skinka/yii2-ordering/messages', 'fileMap' => ['skinka/ordering/core' => 'core.php']]; $model = new $this->model(); $model = $model->find(); if ($this->group !== null && $this->_group_id !== null) { $model = $model->where([$this->group => $this->_group_id]); } $listItems = []; $listItems[] = ['index' => 0, 'value' => Yii::t('skinka/ordering/core', '<< First >>')]; $data = $model->orderBy([$this->keyField => SORT_ASC])->all(); foreach ($data as $item) { $listItems[] = ['index' => $item->{$this->keyField}, 'value' => $item->{$this->valueField}]; } $listItems[] = ['index' => -1, 'value' => Yii::t('skinka/ordering/core', '<< Last >>')]; return ['listItems' => $listItems]; }
/** @inheritdoc */ public function bootstrap($app) { /** @var Module $module */ /** @var \yii\db\ActiveRecord $modelName */ if ($app->hasModule('blog') && ($module = $app->getModule('blog')) instanceof Module) { Yii::$container->setSingleton(BlogFinder::className(), ['tagQuery' => \jarrus90\Blog\Models\Tag::find(), 'postQuery' => \jarrus90\Blog\Models\Post::find(), 'commentQuery' => \jarrus90\Blog\Models\Comment::find()]); if (!$app instanceof ConsoleApplication) { $module->controllerNamespace = 'jarrus90\\Blog\\Controllers'; $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules]; if ($module->urlPrefix != 'blog') { $configUrlRule['routePrefix'] = 'blog'; } $configUrlRule['class'] = 'yii\\web\\GroupUrlRule'; $rule = Yii::createObject($configUrlRule); $app->urlManager->addRules([$rule], false); } else { if (empty($app->controllerMap['migrate'])) { $app->controllerMap['migrate']['class'] = 'yii\\console\\controllers\\MigrateController'; } $app->controllerMap['migrate']['migrationNamespaces'][] = 'jarrus90\\Blog\\migrations'; } if (!isset($app->get('i18n')->translations['blog*'])) { $app->get('i18n')->translations['blog*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US']; } } }
public function safeUp() { $app = Yii::$app; $app->setModule('user', ['class' => 'dektrium\\user\\Module']); if (!isset($app->get('i18n')->translations['user*'])) { $app->get('i18n')->translations['user*'] = ['class' => \yii\i18n\PhpMessageSource::className(), 'basePath' => Yii::getAlias('@dektrium/user/migrations')]; } $controller = Yii::$app->controller; $user = new User(['scenario' => 'register']); echo $controller->ansiFormat("\n\n ==> Create Admin User\n", \yii\helpers\Console::FG_CYAN); do { if ($user->hasErrors()) { $this->showErrors($user); } // get email $email = $controller->prompt($controller->ansiFormat("\tE-mail: ", \yii\helpers\Console::FG_BLUE)); // get username $username = $controller->prompt($controller->ansiFormat("\tUsername: "******"\tPassword: "******"\n"; $affectedRows = Yii::$app->db->createCommand()->insert('{{%user}}', ['username' => (string) $username, 'email' => $email, 'password_hash' => Password::hash($password), 'confirmed_at' => new Expression('UNIX_TIMESTAMP()')])->execute(); } while ($affectedRows < 1); do { // get realname $name = $controller->prompt($controller->ansiFormat("\tFull name: ", \yii\helpers\Console::FG_BLUE)); echo "\n\n"; } while (empty($name)); $userPrimaryKey = User::findOne(['email' => $email])->primaryKey; $this->update('{{%profile}}', ['name' => $name], 'user_id=:user_id', [':user_id' => $userPrimaryKey]); $this->insert('{{%auth_assignment}}', ['item_name' => 'admin', 'user_id' => $userPrimaryKey, 'created_at' => new Expression('UNIX_TIMESTAMP()')]); }
/** * Bootstrap method to be called during application bootstrap stage. * @param Application $app the application currently running */ public function bootstrap($app) { /** @var Module $module */ /** @var \yii\db\ActiveRecord $modelName */ if ($app->hasModule('activeuser') && ($module = $app->getModule('activeuser')) instanceof Module) { $this->_modelMap = array_merge($this->_modelMap, $module->modelMap); foreach ($this->_modelMap as $name => $definition) { $class = "inblank\\activeuser\\models\\" . $name; Yii::$container->set($class, $definition); $modelName = is_array($definition) ? $definition['class'] : $definition; $module->modelMap[$name] = $modelName; } if ($app instanceof ConsoleApplication) { $app->controllerMap['activeuser'] = ['class' => 'inblank\\activeuser\\commands\\DefaultController']; } else { // init user Yii::$container->set('yii\\web\\User', ['loginUrl' => ['/activeuser/account/login'], 'identityClass' => self::di('User')]); $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => defined('IS_BACKEND') ? $module->urlRulesBackend : $module->urlRulesFrontend]; if ($module->urlPrefix != 'activeuser') { $configUrlRule['routePrefix'] = 'activeuser'; } $app->urlManager->addRules([new GroupUrlRule($configUrlRule)], false); if (defined('IS_BACKEND')) { // is backend, and controller have other namespace $module->controllerNamespace = 'inblank\\activeuser\\controllers\\backend'; $module->frontendUrlManager = new yii\web\UrlManager(['baseUrl' => '/', 'enablePrettyUrl' => true, 'showScriptName' => false]); $configUrlRule['rules'] = $module->urlRulesFrontend; $module->frontendUrlManager->addRules([new GroupUrlRule($configUrlRule)], false); } } if (!isset($app->get('i18n')->translations['activeuser*'])) { $app->get('i18n')->translations['activeuser*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } } }
/** * @inheritdoc */ public function init() { $this->role = Rbac::getUserRoleName($this->_user->primaryKey); Yii::setAlias('@rbac', dirname(__DIR__)); Yii::$app->i18n->translations['rbac'] = ['class' => PhpMessageSource::className(), 'basePath' => '@rbac/messages']; parent::init(); }
public function init() { if ($this->message == null) { Yii::$app->getI18n()->translations['iranian-national-code-validator'] = ['class' => \yii\i18n\PhpMessageSource::className(), 'sourceLanguage' => 'en-US', 'basePath' => '@vendor/mohammadhosain/yii2-iranian-national-code-validator/messages']; $this->message = Yii::t('iranian-national-code-validator', '{attribute} is not valid iranian national code.'); } }
/** * @inheritdoc * * Change: Don't show warning if message file don't exists */ protected function loadMessages($category, $language) { $messageFile = $this->getMessageFilePath($category, $language); $messages = $this->loadMessagesFromFile($messageFile); //Used for overwriting the default language files under @app/config/messages/. $configMessageFile = $this->getConfigMessageFilePath($category, $language); $configMessages = parent::loadMessagesFromFile($configMessageFile); if ($messages !== null && $configMessages !== null) { $messages = array_merge($messages, $configMessages); } elseif ($messages === null && $configMessages !== null) { $messages = $configMessages; } $fallbackLanguage = substr($language, 0, 2); if ($fallbackLanguage != $language) { $fallbackMessageFile = $this->getMessageFilePath($category, $fallbackLanguage); $fallbackMessages = $this->loadMessagesFromFile($fallbackMessageFile); if ($messages === null && $fallbackMessages === null && $fallbackLanguage != $this->sourceLanguage) { } elseif (empty($messages)) { return $fallbackMessages; } elseif (!empty($fallbackMessages)) { foreach ($fallbackMessages as $key => $value) { if (!empty($value) && empty($messages[$key])) { $messages[$key] = $fallbackMessages[$key]; } } } } return (array) $messages; }
public function bootstrap($app) { /** @var Module $module */ if ($app->hasModule('cms') && ($module = $app->getModule('cms')) instanceof Module) { $classMap = array_merge($this->classMap, $module->classMap); foreach (array_keys($this->classMap) as $item) { $className = '\\nullref\\cms\\models\\' . $item; $cmsClass = $className::className(); $definition = $classMap[$item]; Yii::$container->set($cmsClass, $definition); } if ($app instanceof WebApplication) { $prefix = $app->getModule('cms')->urlPrefix; $app->urlManager->addRules([Yii::createObject(['class' => PageUrlRule::className(), 'pattern' => $prefix . '/<route:[_a-zA-Z0-9-/]+>'])]); if (!isset($app->controllerMap['elfinder-backend'])) { $app->controllerMap['elfinder-backend'] = ['class' => 'mihaildev\\elfinder\\Controller', 'user' => 'admin', 'access' => ['@'], 'disabledCommands' => ['netmount'], 'roots' => [['path' => 'uploads', 'name' => 'Uploads']]]; } $app->i18n->translations['cms*'] = ['class' => PhpMessageSource::className(), 'basePath' => '@nullref/cms/messages']; } if (YII_ENV_DEV) { Event::on(Gii::className(), Gii::EVENT_BEFORE_ACTION, function (Event $event) { /** @var Gii $gii */ $gii = $event->sender; $gii->generators['block-migration-generator'] = ['class' => 'nullref\\cms\\generators\\block_migration\\Generator']; $gii->generators['block-generator'] = ['class' => 'nullref\\cms\\generators\\block\\Generator']; $gii->generators['pages-migration-generator'] = ['class' => 'nullref\\cms\\generators\\pages_migration\\Generator']; }); } } }
/** @inheritdoc */ public function bootstrap($app) { /** @var Module $module */ /** @var \yii\db\ActiveRecord $modelName */ if ($app->hasModule('multilang') && ($module = $app->getModule('multilang')) instanceof Module) { if (!isset($app->get('i18n')->translations['multilang*'])) { $app->get('i18n')->translations['multilang*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US']; } if (!$app instanceof ConsoleApplication) { $module->controllerNamespace = 'jarrus90\\Multilang\\Controllers'; $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules]; if ($module->urlPrefix != 'multilang') { $configUrlRule['routePrefix'] = 'multilang'; } $configUrlRule['class'] = 'yii\\web\\GroupUrlRule'; $rule = Yii::createObject($configUrlRule); $app->urlManager->addRules([$rule], false); $app->params['admin']['menu']['multilang'] = ['label' => Yii::t('multilang', 'Languages'), 'position' => 90, 'icon' => '<i class="fa fa-fw fa-language"></i>', 'url' => '/multilang/admin/index']; } else { if (empty($app->controllerMap['migrate'])) { $app->controllerMap['migrate']['class'] = 'yii\\console\\controllers\\MigrateController'; } $app->controllerMap['migrate']['migrationNamespaces'][] = 'jarrus90\\Multilang\\migrations'; } } }
/** @inheritdoc */ public function bootstrap($app) { /** @var Module $module */ /** @var \yii\db\ActiveRecord $modelName */ if ($app->hasModule('support') && ($module = $app->getModule('support')) instanceof Module) { Yii::$container->setSingleton(SupportFinder::className(), ['categoryQuery' => \jarrus90\Support\Models\Category::find(), 'pageQuery' => \jarrus90\Support\Models\Page::find()]); if (!isset($app->get('i18n')->translations['support*'])) { $app->get('i18n')->translations['support*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US']; } if (!$app instanceof ConsoleApplication) { $module->controllerNamespace = 'jarrus90\\Support\\Controllers'; $configUrlRule = ['prefix' => $module->urlPrefix, 'rules' => $module->urlRules]; if ($module->urlPrefix != 'support') { $configUrlRule['routePrefix'] = 'support'; } $configUrlRule['class'] = 'yii\\web\\GroupUrlRule'; $rule = Yii::createObject($configUrlRule); $app->urlManager->addRules([$rule], false); $app->params['admin']['menu']['support'] = function () use($module) { return $module->getAdminMenu(); }; } else { if (empty($app->controllerMap['migrate'])) { $app->controllerMap['migrate']['class'] = 'yii\\console\\controllers\\MigrateController'; } $app->controllerMap['migrate']['migrationNamespaces'][] = 'jarrus90\\Support\\migrations'; } } }
/** * @inheritdoc */ public function bootstrap($app) { Yii::setAlias('@roboapp-admin', __DIR__); if (!isset($app->get('i18n')->translations[Module::$moduleName . '*'])) { $app->get('i18n')->translations[Module::$moduleName . '*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } $this->activeModules(); }
/** @inheritdoc */ public function bootstrap($app) { if ($app instanceof \yii\web\Application) { } $app->setComponents(['settings' => ['class' => 'esoftslimited\\settings\\components\\Settings']]); if (!isset($app->get('i18n')->translations['settings*'])) { $app->get('i18n')->translations['settings*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } }
/** @inheritdoc */ public function bootstrap($app) { /** @var Module $module */ /** @var \yii\db\ActiveRecord $modelName */ if ($app->hasModule('core') && ($module = $app->getModule('core')) instanceof Module) { if (!isset($app->get('i18n')->translations['core*'])) { $app->get('i18n')->translations['core*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US']; } } }
/** @inheritdoc */ public function bootstrap($app) { /* Config Translation */ if (!isset($app->get('i18n')->translations['adminlte*'])) { $app->get('i18n')->translations['adminlte*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } /* Config Theme */ if (!isset($app->view->theme)) { $app->view->theme = new \yii\base\Theme(['pathMap' => ['@app/views/layouts' => '@cjtterabytesoft/adminlte/basic/views/layouts', '@app/views/site' => '@cjtterabytesoft/adminlte/basic/views/site']]); } /* Copy Avatar Images */ if (\yii\helpers\BaseFileHelper::filterPath(\Yii::getAlias('@app/web/images'), $options = [])) { \yii\helpers\BaseFileHelper::copyDirectory(\Yii::getAlias('@cjtterabytesoft/adminlte/basic/images/'), \Yii::getAlias('@app/web/images')); } /* Config Params */ if (!isset($app->params['adminEmail'])) { $app->params['adminEmail'] = '*****@*****.**'; } if (!isset($app->params['AdminLTESkin'])) { $app->params['AdminLTESkin'] = 'skin-yellow'; } if (!isset($app->params['Author'])) { $app->params['Author'] = '2015 - Wilmer Arambula'; } if (!isset($app->params['Facebook_Account'])) { $app->params['Facebook_Account'] = 'https://www.facebook.com/username'; } if (!isset($app->params['Google_Account'])) { $app->params['Google_Account'] = 'https://www.google.com/+username'; } if (!isset($app->params['Linkedin_Account'])) { $app->params['Linkedin_Account'] = 'https://www.linkedin.com/in/username'; } if (!isset($app->params['Twitter_Account'])) { $app->params['Twitter_Account'] = 'https://twitter.com/username'; } if (!isset($app->params['WebName'])) { $app->params['WebName'] = 'My Application'; } if (!YII_ENV_TEST) { if (!isset($app->params['imagesurl_30'])) { $app->params['imagesurl_30'] = 'http://www.basic.tk/images/avatar/profile/30/icon-avatar.png'; } if (!isset($app->params['imagesurl_60'])) { $app->params['imagesurl_60'] = 'http://www.basic.tk/images/avatar/profile/60/icon-avatar.png'; } } else { if (!isset($app->params['imagesurl_30'])) { $app->params['imagesurl_30'] = 'http://localhost.basic/images/avatar/profile/30/icon-avatar.png'; } if (!isset($app->params['imagesurl_60'])) { $app->params['imagesurl_60'] = 'http://localhost.basic/images/avatar/profile/60/icon-avatar.png'; } } }
public function init() { parent::init(); $this->locator = new ServiceLocator(); $this->initConfigurator(); $this->setDbAdapter(); $this->initElastica(); if (!isset(Yii::$app->get('i18n')->translations['analytics'])) { Yii::$app->get('i18n')->translations['analytics'] = ['class' => \yii\i18n\PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'sourceLanguage' => 'en-US']; } }
/** @inheritdoc */ public function bootstrap($app) { /* Config Translation */ if (!isset($app->get('i18n')->translations['adminlte*'])) { $app->get('i18n')->translations['adminlte*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } /* Copy Avatar Images */ if (\yii\helpers\BaseFileHelper::filterPath(\Yii::getAlias('@frontend/web/images'), $options = [])) { \yii\helpers\BaseFileHelper::copyDirectory(\Yii::getAlias('@cjtterabytesoft/adminlte/advanced/images/'), \Yii::getAlias('@frontend/web/images')); } }
public function bootstrap($app) { $classMap = array_merge($this->_classMap, $this->classMap); foreach (array_keys($this->classMap) as $item) { $className = '\\nullref\\geo\\models\\' . $item; $geoClass = $className::className(); $definition = $classMap[$item]; Yii::$container->set($geoClass, $definition); } if ($app instanceof WebApplication) { $app->i18n->translations['geo*'] = ['class' => PhpMessageSource::className(), 'basePath' => '@nullref/geo/messages']; } }
/** * @inheritdoc */ public function bootstrap($app) { /** @var $module Module */ if ($app->hasModule('qa') && ($module = $app->getModule('qa')) instanceof Module) { if ($app instanceof ConsoleApplication) { $module->controllerNamespace = 'artkost\\qa\\commands'; } else { if (!class_exists($app->get('user')->identityClass)) { throw new InvalidConfigException('Yii::$app->user->identityClass does not exist'); } } } $app->i18n->translations[Module::TRANSLATION . '*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'fileMap' => [Module::TRANSLATION . 'main' => 'main.php', Module::TRANSLATION . 'model' => 'model.php']]; }
/** * Bootstrap method to be called during application bootstrap stage. * * @param Application $app the application currently running */ public function bootstrap($app) { /** @var Module $module */ if ($app->hasModule('user') && ($module = $app->getModule('user')) instanceof Module) { if (!isset($app->get('i18n')->translations['user*'])) { $app->get('i18n')->translations['user*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } if ($app instanceof ConsoleApplication) { $module->controllerNamespace = 'johnitvn\\userplus\\commands'; } else { $module->controllerNamespace = 'johnitvn\\userplus\\controllers'; } } }
public function init() { if ($this->controllerNamespace === null) { $class = get_class($this); if (($pos = strrpos($class, '\\')) !== false) { $this->controllerNamespace = substr($class, 0, $pos) . '\\controllers\\' . Yii::$app->id; } } //Set path to views for module application $this->setViewPath($this->getBasePath() . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . Yii::$app->id); //Add translations folder Yii::$app->get('i18n')->translations[$this->id . '*'] = ['class' => PhpMessageSource::className(), 'basePath' => $this->basePath . '/messages']; parent::init(); }
protected function loadMessages($category, $language) { $messages = parent::loadMessages($category, $language); if (strpos($category, '*') > 0) { return $messages; } $key = $category . '/' . $language; if (!isset($this->_parentMessages[$key])) { $parent = Yii::$app->getI18n()->getMessageSource($category . '*'); $oldMessages = $parent->loadMessages($category, $language); $this->_parentMessages[$key] = array_merge($oldMessages, array_filter($messages)); } return $this->_parentMessages[$key]; }
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) { $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']; } }
/** * Bootstrap method to be called during application bootstrap stage. * @param Application $app the application currently running */ public function bootstrap($app) { $classMap = array_merge($this->_classMap, $this->classMap); foreach (['Category', 'CategoryQuery'] as $item) { $className = __NAMESPACE__ . '\\models\\' . $item; $postClass = $className::className(); $definition = $classMap[$item]; Yii::$container->set($postClass, $definition); } if ($app instanceof WebApplication) { if (!isset($app->i18n->translations['category*'])) { $app->i18n->translations['category*'] = ['class' => PhpMessageSource::className(), 'basePath' => '@nullref/category/messages']; } } }
/** @inheritdoc */ public function bootstrap($app) { /** @var Module $module */ /** @var \yii\db\ActiveRecord $modelName */ if ($app->hasModule('main') && ($module = $app->getModule('main')) instanceof Module) { if ($app instanceof ConsoleApplication) { } else { $configUrlRule = ['prefix' => $module->urlPrefix, 'routePrefix' => $module->routePrefix, 'rules' => $module->urlRules]; $app->urlManager->addRules([new GroupUrlRule($configUrlRule)], false); } if (!isset($app->get('i18n')->translations['main*'])) { $app->get('i18n')->translations['main*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; } } }
/** * @inheritdoc */ public function init() { parent::init(); Yii::setAlias('@tree', dirname(__DIR__)); Yii::$app->i18n->translations['tree'] = ['class' => PhpMessageSource::className(), 'basePath' => '@tree/messages']; if (!isset($this->options['id'])) { $this->options['id'] = $this->getId(); } $clientEvents = ['create_node' => 'yii.tree.createNode', 'move_node' => 'yii.tree.moveNode', 'rename_node' => 'yii.tree.renameNode', 'delete_node' => 'yii.tree.deleteNode']; $model = new $this->modelClass(); if ($model->saveState) { $clientEvents = array_merge($clientEvents, ['open_node' => 'yii.tree.openNode', 'close_node' => 'yii.tree.closeNode']); } $items = ['create' => ['label' => Yii::t('tree', 'Create')], 'rename' => ['label' => Yii::t('tree', 'Rename')], 'remove' => ['label' => Yii::t('tree', 'Remove')]]; if ($this->updateUrl) { $items['update'] = ['label' => Yii::t('tree', 'Update')]; } $this->jsTreeOptions = ArrayHelper::merge(['clientOptions' => ['core' => ['data' => ['url' => Url::to(['/tree/get-tree', 'modelClass' => $this->modelClass])], 'check_callback' => true, 'strings' => ['New node' => Yii::t('tree', 'New node')]], 'plugins' => ['contextmenu', 'dnd'], 'contextmenu' => ['items' => $items]], 'clientEvents' => $clientEvents], $this->jsTreeOptions); }
/** @inheritdoc */ public function bootstrap($app) { /** @var $module Module */ if ($app->hasModule('configmanager') && ($module = $app->getModule('configmanager')) instanceof Module) { $this->_modelMap = array_merge($this->_modelMap, $module->modelMap); foreach ($this->_modelMap as $name => $definition) { $class = "chd7well\\configmanager\\models\\" . $name; \Yii::$container->set($class, $definition); $modelName = is_array($definition) ? $definition['class'] : $definition; $module->modelMap[$name] = $modelName; if (in_array($name, ['Configmanager'])) { \Yii::$container->set($name . 'Query', function () use($modelName) { return $modelName::find(); }); } } } $app->get('i18n')->translations['configmanager*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages']; //Load parameters from database $parameters = Parameter::find()->where(['bootstrap' => '1'])->all(); //only on bootstrap are necessary foreach ($parameters as $para) { $this->setParameter($app, $para->parametername, $para->value); } $is_config_set = Parameter::findOne(['parametername' => 'chd7well/configmanager/config_set']); $is_user_config_set = Parameter::findOne(['parametername' => 'chd7well/configmanager/user_parameter']); if (get_class(\Yii::$app) === 'yii\\web\\Application') { if (isset($app->params['chd7well/configmanager/config_set']) && isset($app->params['chd7well/configmanager/user_parameter']) && $app->params['chd7well/configmanager/config_set'] == 1 && $app->params['chd7well/configmanager/user_parameter'] == 1 && isset(\Yii::$app->user->id)) { $configuser = ConfigUser::findOne(['user_ID' => \Yii::$app->user->id]); if (isset($configuser)) { $config = Config::findOne(['ID' => $configuser->config_ID]); $parent_parameters = ConfigParameter::find()->where(['config_ID' => $config->parent_ID])->all(); $user_parameters = ConfigParameter::find()->where(['config_ID' => $config->ID])->all(); foreach ($parent_parameters as $para) { $this->setParameter($app, $para->parameter->parametername, $para->value); } foreach ($user_parameters as $para) { $this->setParameter($app, $para->parameter->parametername, $para->value); } } } } }