-
Notifications
You must be signed in to change notification settings - Fork 0
/
Module.php
75 lines (63 loc) · 2.14 KB
/
Module.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
72
73
74
75
<?php
namespace thyseus\sitecontent;
use Yii;
use yii\i18n\PhpMessageSource;
/**
* Sitecontent module definition class
*/
class Module extends \yii\base\Module
{
public $version = '0.1.0-dev';
/**
* @inheritdoc
*/
public $controllerNamespace = 'thyseus\sitecontent\controllers';
public $defaultRoute = 'sitecontent\sitecontent\index';
/**
* @var string The layout to be used by the view action. Keep null to use the default layout.
*/
public $layout = null;
/**
* @var string The class of the User Model inside the application this module is attached to
*/
public $userModelClass = 'app\models\User';
/**
* @var array|false Options for the Summernote WYSIWYG editor plugin. Set to false to disable the plugin.
*/
public $summernoteOptions = [
'clientOptions' => [],
];
/**
* @var callback Rule to determine which users are allowed to access the content management system.
* Defaults to Yii::$app->user->can('admin')
*/
public $accessCallback = null;
/** @var array The rules to be used in URL management. */
public $urlRules = [
'sitecontent/update/<language>/<id>' => 'sitecontent/sitecontent/update',
'sitecontent/delete/<language>/<id>' => 'sitecontent/sitecontent/delete',
'sitecontent/<language>/<id>' => 'sitecontent/sitecontent/view',
'sitecontent/index' => 'sitecontent/sitecontent/index',
'sitecontent/create' => 'sitecontent/sitecontent/create',
'sitecontent/<id>' => 'sitecontent/sitecontent/view',
];
/**
* @inheritdoc
*/
public function init()
{
if (!$this->accessCallback) {
$this->accessCallback = function () {
return Yii::$app->user->can('admin');
};
}
if (!isset(Yii::$app->get('i18n')->translations['sitecontent*'])) {
Yii::$app->get('i18n')->translations['sitecontent*'] = [
'class' => PhpMessageSource::className(),
'basePath' => __DIR__ . '/messages',
'sourceLanguage' => 'en-US'
];
}
parent::init();
}
}