Module.php
2.17 KB
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
<?php
namespace common\modules\comment;
/**
* Class Module
* @package common\modules\comment
*/
class Module extends \yii\base\Module
{
/**
* @var string Module name
*/
public static $moduleName = 'artbox_comment';
/**
* @var bool Wheather to use Rbac system
* @link http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#rbac
* @see \yii\rbac\ManagerInterface
*/
public $useRbac = false;
/**
* Array of RBAC rules and permissions that can be used by install command.
*
* Currently supports associative array, of such view:
*
* <code>
* [
* 'rules' => [
* \full\namapaced\ClassName,
* \another\one\ClassName,
* ],
* 'permissions' => [
* [
* 'name' => stringName,
* 'description' => descriptionText,
* 'ruleName' => (new \full\namespaced\ClassName())->name (optional)
* ],
* [
* 'name' => stringName2,
* 'description' => descriptionText2,
* 'ruleName' => (new \another\one\ClassName())->name (optional)
* ],
* ]
* ]
* </code>
*
* @var array
* @see \common\modules\comment\commands\RbacController
*/
public $rbac = [];
/**
* @var \yii\db\Connection Connection to the db
*/
public $db = null;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if(\Yii::$app instanceof \yii\console\Application) {
$this->controllerNamespace = 'common\modules\comment\commands';
}
if($this->db === null) {
$this->db = \Yii::$app->db;
} elseif(!$this->db instanceof \yii\db\Connection) {
throw new \yii\base\InvalidConfigException('Конфиг db обязан наследоваться от'.\yii\db\Connection::className());
}
}
}