-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathBootstrap.php
71 lines (64 loc) · 2.76 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?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 dmstr\modules\pages\components\PageUrlRule;
use dmstr\modules\pages\models\Tree;
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') && !\Yii::$app->hasModule('treemanager')) {
$app->setModule(
'treemanager',
[
'class' => 'kartik\tree\Module',
'layout' => '@admin-views/layouts/main',
'treeViewSettings' => [
'nodeView' => '@vendor/dmstr/yii2-pages-module/views/treeview/_form',
'fontAwesome' => true,
],
]
);
}
// provide default page url rule
$app->urlManager->addRules(
[
// pages default page route
['class' => PageUrlRule::className()],
[
'pattern' => 'p/<'.Tree::REQUEST_PARAM_PATH.':[a-zA-Z0-9_\-\./\+]*>/<'.Tree::REQUEST_PARAM_SLUG.':[a-zA-Z0-9_\-\.]*>-<'.Tree::REQUEST_PARAM_ID.':[0-9]*>.html',
'route' => 'pages/default/page',
'encodeParams' => false,
],
'p/<'.Tree::REQUEST_PARAM_SLUG.':[a-zA-Z0-9_\-\.]*>-<'.Tree::REQUEST_PARAM_ID.':[0-9]*>.html' => 'pages/default/page',
// Backward compatibility
'page/<'.Tree::REQUEST_PARAM_PATH.':[a-zA-Z0-9_\-\./\+]*>/<'.Tree::REQUEST_PARAM_SLUG.':[a-zA-Z0-9_\-\.]*>-<'.Tree::REQUEST_PARAM_ID.':[0-9]*>.html' => 'pages/default/page',
'page/<'.Tree::REQUEST_PARAM_SLUG.':[a-zA-Z0-9_\-\.]*>-<'.Tree::REQUEST_PARAM_ID.':[0-9]*>.html' => 'pages/default/page',
'<'.Tree::REQUEST_PARAM_PATH.':[a-zA-Z0-9_\-\./\+]*>/<'.Tree::REQUEST_PARAM_SLUG.':[a-zA-Z0-9_\-\.]*>-<'.Tree::REQUEST_PARAM_ID.':[0-9]*>' => 'pages/default/page',
'<'.Tree::REQUEST_PARAM_SLUG.':[a-zA-Z0-9_\-\.]*>-<'.Tree::REQUEST_PARAM_ID.':[0-9]*>' => 'pages/default/page',
],
true
);
}
}