Module::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @link      http://www.writesdown.com/
4
 * @copyright Copyright (c) 2015 WritesDown
5
 * @license   http://www.writesdown.com/license/
6
 */
7
8
namespace modules\sitemap\frontend;
9
10
use yii\base\Application;
11
use yii\base\BootstrapInterface;
12
13
/**
14
 * Class Module
15
 *
16
 * @author  Agiel K. Saputra <[email protected]>
17
 * @since   0.2.0
18
 */
19
class Module extends \yii\base\Module implements BootstrapInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    public $controllerNamespace = 'modules\sitemap\frontend\controllers';
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function init()
30
    {
31
        parent::init();
32
33
        // custom initialization code goes here
34
    }
35
36
    /**
37
     * Bootstrap method to be called during application bootstrap stage.
38
     *
39
     * @param Application $app the application currently running
40
     */
41
    public function bootstrap($app)
42
    {
43
        $app->getUrlManager()->addRules([
44
            [
45
                'pattern' => $this->id,
46
                'route'   => $this->id . '/default/index',
47
                'suffix'  => '.xml',
48
            ],
49
            [
50
                'pattern' => $this->id . '/<type:[\w-@]+>/<slug:[\w-@]+>-<page:\d+>',
51
                'route'   => $this->id . '/default/view',
52
                'suffix'  => '.xml',
53
            ],
54
            [
55
                'pattern' => $this->id . '/<type:[\w-@]+>/<slug:[\w-@]+>',
56
                'route'   => $this->id . '/default/view',
57
                'suffix'  => '.xml',
58
            ],
59
            $this->id                                  => '/site/not-found',
60
            $this->id . '/default/'                    => '/site/not-found',
61
            $this->id . '/default/<alias:index|view>/' => '/site/not-found',
62
        ], false);
63
    }
64
}
65