Bootstrap.php 1.34 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
<?php
Aster's avatar
Aster committed
2

Aster's avatar
Aster committed
3
namespace arter\amos\audit;
Marcello Pivanti's avatar
Marcello Pivanti committed
4
5
6
7
8
9

use yii\base\Application;
use yii\base\BootstrapInterface;

/**
 * Bootstrap
Aster's avatar
Aster committed
10
 * @package arter\amos\audit
Marcello Pivanti's avatar
Marcello Pivanti committed
11
12
13
14
15
16
17
18
19
20
21
 */
class Bootstrap implements BootstrapInterface
{
    /**
     * Bootstrap method to be called during application bootstrap stage.
     *
     * @param Application $app the application currently running
     */
    public function bootstrap($app)
    {
        // Make sure to register the base folder as alias as well or things like assets won't work anymore
Aster's avatar
Aster committed
22
        \Yii::setAlias('@arter/amos/audit', __DIR__);
Marcello Pivanti's avatar
Marcello Pivanti committed
23
24

        if ($app instanceof \yii\console\Application) {
Aster's avatar
Aster committed
25
            $app->controllerMap['audit'] = 'arter\amos\audit\commands\AuditController';
Marcello Pivanti's avatar
Marcello Pivanti committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        }
        
        $moduleName = Audit::findModuleIdentifier();
        
        if ($moduleName) {
            // The module was added in the configuration, make sure to add it to the application bootstrap so it gets loaded
            $app->bootstrap[] = $moduleName;
            $app->bootstrap = array_unique($app->bootstrap, SORT_REGULAR);
        }
        
        if ($app->has('i18n')) {
            $app->i18n->translations['audit'] = [
                'class'          => 'yii\i18n\PhpMessageSource',
                'sourceLanguage' => 'en',
Aster's avatar
Aster committed
40
                'basePath'       => '@arter/amos/audit/messages',
Marcello Pivanti's avatar
Marcello Pivanti committed
41
42
43
44
45
            ];
        }
        
    }
}