forked from dmstr/yii2-pages-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bootstrap.php
52 lines (47 loc) · 1.41 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
45
46
47
48
49
50
51
52
<?php
/**
* @link http://www.diemeisterei.de/
* @copyright Copyright (c) 2015 diemeisterei GmbH, Stuttgart
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace dmstr\modules\pages;
use yii\base\Application;
use yii\base\BootstrapInterface;
/**
* Class Bootstrap
* @package dmstr\modules\pages
* @author Marc Mautz <[email protected]>
*/
class Bootstrap implements BootstrapInterface
{
/**
* Bootstrap method to be called during application bootstrap stage.
*
* @param Application $app the application currently running
*/
public function bootstrap($app)
{
// register migration
$app->params['yii.migrations'][] = '@vendor/dmstr/yii2-pages-module/migrations';
// register module
if (!\Yii::$app->hasModule('pages')) {
$app->setModule(
'pages',
[
'class' => 'dmstr\modules\pages\Module'
]
);
}
// provide default page url rule
$app->urlManager->addRules(
[
// pages default page route
'<parentLeave:[a-zA-Z0-9_\-\.]*>/<pageName:[a-zA-Z0-9_\-\.]*>-<id:[0-9]*>' => 'pages/default/page',
'<pageName:[a-zA-Z0-9_\-\.]*>-<id:[0-9]*>' => 'pages/default/page',
],
true
);
}
}