Skip to content

Commit

Permalink
Merge pull request #85 from btommboy/master
Browse files Browse the repository at this point in the history
add db connection to module settings
  • Loading branch information
lajax authored Jul 12, 2016
2 parents 5215e3c + 81c1d8c commit 1dd264a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ class Module extends \yii\base\Module {
*/
public $defaultExportFormat = Response::FORMAT_JSON;

/**
* @var string The default db connection
*/
public $connection = 'db';

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -303,6 +308,7 @@ public function checkAccess() {
*/
public function getLanguageItemsDirPath() {
return Yii::getAlias($this->tmpDir) . $this->subDir;
}

}


}
7 changes: 7 additions & 0 deletions models/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class Language extends \yii\db\ActiveRecord {
self::STATUS_BETA => 'Beta',
];

/**
* @inheritdoc
*/
public static function getDb() {
return Yii::$app->get(Yii::$app->getModule('translatemanager')->connection);
}

/**
* @inheritdoc
*/
Expand Down
9 changes: 9 additions & 0 deletions models/LanguageSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ class LanguageSource extends \yii\db\ActiveRecord

const INSERT_LANGUAGE_ITEMS_LIMIT = 10;

/**
* @inheritdoc
*/
public static function getDb()
{
$dbMessageSources = Yii::getObjectVars(Yii::$app->i18n->getMessageSource('DbMessageSource'));
return $dbMessageSources['db'];
}

/**
* @inheritdoc
*/
Expand Down
8 changes: 8 additions & 0 deletions models/LanguageTranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class LanguageTranslate extends \yii\db\ActiveRecord {
*/
public $cnt;

/**
* @inheritdoc
*/
public static function getDb() {
$dbMessageSources = Yii::getObjectVars(Yii::$app->i18n->getMessageSource('DbMessageSource'));
return $dbMessageSources['db'];
}

/**
* @inheritdoc
*/
Expand Down

0 comments on commit 1dd264a

Please sign in to comment.