Skip to content

Commit 1dd264a

Browse files
authored
Merge pull request #85 from btommboy/master
add db connection to module settings
2 parents 5215e3c + 81c1d8c commit 1dd264a

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

Module.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ class Module extends \yii\base\Module {
272272
*/
273273
public $defaultExportFormat = Response::FORMAT_JSON;
274274

275+
/**
276+
* @var string The default db connection
277+
*/
278+
public $connection = 'db';
279+
275280
/**
276281
* @inheritdoc
277282
*/
@@ -303,6 +308,7 @@ public function checkAccess() {
303308
*/
304309
public function getLanguageItemsDirPath() {
305310
return Yii::getAlias($this->tmpDir) . $this->subDir;
306-
}
307-
311+
}
312+
313+
308314
}

models/Language.php

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ class Language extends \yii\db\ActiveRecord {
5050
self::STATUS_BETA => 'Beta',
5151
];
5252

53+
/**
54+
* @inheritdoc
55+
*/
56+
public static function getDb() {
57+
return Yii::$app->get(Yii::$app->getModule('translatemanager')->connection);
58+
}
59+
5360
/**
5461
* @inheritdoc
5562
*/

models/LanguageSource.php

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ class LanguageSource extends \yii\db\ActiveRecord
2727

2828
const INSERT_LANGUAGE_ITEMS_LIMIT = 10;
2929

30+
/**
31+
* @inheritdoc
32+
*/
33+
public static function getDb()
34+
{
35+
$dbMessageSources = Yii::getObjectVars(Yii::$app->i18n->getMessageSource('DbMessageSource'));
36+
return $dbMessageSources['db'];
37+
}
38+
3039
/**
3140
* @inheritdoc
3241
*/

models/LanguageTranslate.php

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ class LanguageTranslate extends \yii\db\ActiveRecord {
2626
*/
2727
public $cnt;
2828

29+
/**
30+
* @inheritdoc
31+
*/
32+
public static function getDb() {
33+
$dbMessageSources = Yii::getObjectVars(Yii::$app->i18n->getMessageSource('DbMessageSource'));
34+
return $dbMessageSources['db'];
35+
}
36+
2937
/**
3038
* @inheritdoc
3139
*/

0 commit comments

Comments
 (0)