a2cde075
Yarik
first commit
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<?php
namespace artweb\artbox\comment;
use artweb\artbox\comment\models\CommentModel;
use artweb\artbox\comment\models\RatingModel;
use Yii;
use yii\console\Application;
/**
* Class Module
* @package artweb\artbox\comment
*/
class Module extends \yii\base\Module
{
|
a2cde075
Yarik
first commit
|
17
18
19
20
21
22
|
/**
* @var string module name
*/
public static $name = 'artbox-comment';
/**
|
0bacad2e
Yarik
Namespaces
|
23
|
* User identity class, default to artweb\artbox\comment\models\User
|
a2cde075
Yarik
first commit
|
24
25
26
27
28
|
* @var string|null
*/
public $userIdentityClass = NULL;
/**
|
0bacad2e
Yarik
Namespaces
|
29
|
* Comment model class, default to artweb\artbox\comment\modules\models\CommentModel
|
a2cde075
Yarik
first commit
|
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
|
* @var string comment model class
*/
public $commentModelClass = NULL;
public $ratingModelClass = NULL;
/**
* This namespace will be used to load controller classes by prepending it to the controller
* class name.
* @var string the namespace that controller classes are in.
*/
public $controllerNamespace = 'artweb\artbox\comment\controllers';
/**
* @var \yii\db\Connection DB connection, default to \Yii::$app->db
*/
public $db = NULL;
/**
* Key, used to encrypt and decrypt comment service data.
* @var string Encryption key
*/
public static $encryptionKey = 'artbox-comment';
/**
* Whether to enable comment rating or not.
* @var bool
*/
public static $enableRating = true;
/**
* Initializes the module.
* This method is called after the module is created and initialized with property values
* given in configuration. The default implementation will initialize
* [[controllerNamespace]] if it is not set. If you override this method, please make sure
* you call the parent implementation.
*/
public function init()
{
|
a2cde075
Yarik
first commit
|
69
70
71
72
73
74
75
76
|
if($this->commentModelClass === NULL) {
$this->commentModelClass = CommentModel::className();
}
if(self::$enableRating && $this->ratingModelClass === NULL) {
$this->ratingModelClass = RatingModel::className();
}
if(\Yii::$app instanceof Application) {
$this->controllerNamespace = 'artweb\artbox\comment\commands';
|
395a7b37
Yarik
Module fix
|
77
78
|
} elseif($this->userIdentityClass === NULL) {
$this->userIdentityClass = Yii::$app->getUser()->identityClass;
|
a2cde075
Yarik
first commit
|
79
80
81
82
83
84
85
86
87
|
}
if($this->db === NULL) {
$this->db = \Yii::$app->db;
}
Yii::setAlias('@artbox-comment', __DIR__);
parent::init();
}
}
|