-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathBootstrap.php
44 lines (39 loc) · 1.39 KB
/
Bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace artkost\qa;
use artkost\qa\models\Answer;
use artkost\qa\models\Question;
use Yii;
use yii\base\BootstrapInterface;
use yii\base\InvalidConfigException;
use yii\console\Application as ConsoleApplication;
use yii\i18n\PhpMessageSource;
use artkost\qa\Module;
class Bootstrap implements BootstrapInterface
{
/**
* @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'
]
];
Yii::$container->set('artkost\qa\models\AnswerInterface', Answer::className());
Yii::$container->set('artkost\qa\models\QuestionInterface', Question::className());
}
}