Skip to content

Commit 0e1f9c1

Browse files
committed
update
1 parent 474e041 commit 0e1f9c1

16 files changed

+71
-75
lines changed

CommentAsset.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?php
22

3-
namespace yii2mod\comments;
3+
namespace coderseden\cmt;
44

55
use yii\web\AssetBundle;
66

77
/**
88
* Class CommentAsset
99
*
10-
* @package yii2mod\comments
10+
* @package coderseden\cmt
1111
*/
1212
class CommentAsset extends AssetBundle
1313
{
1414
/**
1515
* @inheritdoc
1616
*/
17-
public $sourcePath = '@vendor/yii2mod/yii2-comments/assets';
17+
public $sourcePath = '@vendor/coderseden/cmt/assets';
1818

1919
/**
2020
* @inheritdoc

Module.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace yii2mod\comments;
3+
namespace coderseden\cmt;
44

55
use Yii;
66

77
/**
88
* Class Module
99
*
10-
* @package yii2mod\comments
10+
* @package coderseden\cmt
1111
*/
1212
class Module extends \yii\base\Module
1313
{
@@ -17,14 +17,14 @@ class Module extends \yii\base\Module
1717
public $userIdentityClass;
1818

1919
/**
20-
* @var string the class name of the comment model object, by default its yii2mod\comments\models\CommentModel
20+
* @var string the class name of the comment model object, by default its coderseden\cmt\models\CommentModel
2121
*/
22-
public $commentModelClass = 'yii2mod\comments\models\CommentModel';
22+
public $commentModelClass = 'coderseden\cmt\models\CommentModel';
2323

2424
/**
2525
* @var string the namespace that controller classes are in
2626
*/
27-
public $controllerNamespace = 'yii2mod\comments\controllers';
27+
public $controllerNamespace = 'coderseden\cmt\controllers';
2828

2929
/**
3030
* @var bool when admin can edit comments on frontend
@@ -37,8 +37,9 @@ class Module extends \yii\base\Module
3737
public function init()
3838
{
3939
parent::init();
40+
4041
if (null === $this->userIdentityClass) {
41-
$this->userIdentityClass = ($this->params['commentsIdentityClass']) ? $this->params['commentsIdentityClass'] : Yii::$app->getUser()->identityClass;
42+
$this->userIdentityClass = Yii::$app->getUser()->identityClass;
4243
}
4344
}
4445
}

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
This module provides a comments managing system.
1010

11-
[![Latest Stable Version](https://poser.pugx.org/yii2mod/yii2-comments/v/stable)](https://packagist.org/packages/yii2mod/yii2-comments)
12-
[![Total Downloads](https://poser.pugx.org/yii2mod/yii2-comments/downloads)](https://packagist.org/packages/yii2mod/yii2-comments)
13-
[![License](https://poser.pugx.org/yii2mod/yii2-comments/license)](https://packagist.org/packages/yii2mod/yii2-comments)
14-
[![Build Status](https://travis-ci.org/yii2mod/yii2-comments.svg?branch=master)](https://travis-ci.org/yii2mod/yii2-comments)
15-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yii2mod/yii2-comments/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yii2mod/yii2-comments/?branch=master)
11+
[![Latest Stable Version](https://poser.pugx.org/coderseden/cmt/v/stable)](https://packagist.org/packages/coderseden/cmt)
12+
[![Total Downloads](https://poser.pugx.org/coderseden/cmt/downloads)](https://packagist.org/packages/coderseden/cmt)
13+
[![License](https://poser.pugx.org/coderseden/cmt/license)](https://packagist.org/packages/coderseden/cmt)
14+
[![Build Status](https://travis-ci.org/coderseden/cmt.svg?branch=master)](https://travis-ci.org/coderseden/cmt)
15+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/coderseden/cmt/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/coderseden/cmt/?branch=master)
1616

1717
Installation
1818
------------
@@ -22,13 +22,13 @@ The preferred way to install this extension is through [composer](http://getcomp
2222
Either run
2323

2424
```
25-
php composer.phar require --prefer-dist yii2mod/yii2-comments "*"
25+
php composer.phar require --prefer-dist coderseden/cmt "*"
2626
```
2727

2828
or add
2929

3030
```
31-
"yii2mod/yii2-comments": "*"
31+
"coderseden/cmt": "*"
3232
```
3333

3434
to the require section of your composer.json.
@@ -41,7 +41,7 @@ Configuration
4141

4242
Before using Comments Widget, we'll also need to prepare the database.
4343
```php
44-
php yii migrate --migrationPath=@vendor/yii2mod/yii2-comments/migrations
44+
php yii migrate --migrationPath=@vendor/coderseden/cmt/migrations
4545
```
4646

4747
**Module setup**
@@ -50,11 +50,11 @@ To access the module, you need to add the following code to your application con
5050
```php
5151
'modules' => [
5252
'comment' => [
53-
'class' => 'yii2mod\comments\Module',
53+
'class' => 'coderseden\cmt\Module',
5454
],
5555
]
5656
```
57-
>**NOTE:** Module id must be `comment` and not otherwise. This is because it is referred [somewhere](https://github.com/yii2mod/yii2-comments/blob/master/traits/ModuleTrait.php#L20) in the code with such name. A PR to fix it to use configured module id is welcome.
57+
>**NOTE:** Module id must be `comment` and not otherwise. This is because it is referred [somewhere](https://github.com/coderseden/cmt/blob/master/traits/ModuleTrait.php#L20) in the code with such name. A PR to fix it to use configured module id is welcome.
5858
5959
Now you can access to management section through the following URL:
6060
http://localhost/path/to/index.php?r=comments/index
@@ -91,27 +91,27 @@ Usage
9191
// the model to which are added comments, for example:
9292
$model = Post::find()->where(['title' => 'some post title'])->one();
9393

94-
<?php echo \yii2mod\comments\widgets\Comment::widget([
94+
<?php echo \coderseden\cmt\widgets\Comment::widget([
9595
'model' => $model,
9696
]); ?>
9797
```
9898

9999
**You can use your own template for render comments:**
100100

101101
```php
102-
<?php echo \yii2mod\comments\widgets\Comment::widget([
102+
<?php echo \coderseden\cmt\widgets\Comment::widget([
103103
'model' => $model,
104104
'commentView' => '@app/views/site/comments/index' // path to your template
105105
]); ?>
106106
```
107107

108108
**Use the following code for multiple widgets on the same page:**
109109
```php
110-
<?php echo \yii2mod\comments\widgets\Comment::widget([
110+
<?php echo \coderseden\cmt\widgets\Comment::widget([
111111
'model' => $model,
112112
]); ?>
113113

114-
<?php echo \yii2mod\comments\widgets\Comment::widget([
114+
<?php echo \coderseden\cmt\widgets\Comment::widget([
115115
'model' => $model2,
116116
'formId' => 'comment-form2',
117117
'pjaxContainerId' => 'unique-pjax-container-id'
@@ -120,7 +120,7 @@ $model = Post::find()->where(['title' => 'some post title'])->one();
120120

121121
**To enable the pagination for comments list use the following code:**
122122
```php
123-
<?php echo \yii2mod\comments\widgets\Comment::widget([
123+
<?php echo \coderseden\cmt\widgets\Comment::widget([
124124
'model' => $model,
125125
'dataProviderConfig' => [
126126
'pagination' => [
@@ -132,7 +132,7 @@ $model = Post::find()->where(['title' => 'some post title'])->one();
132132

133133
**Advanced example:**
134134
```php
135-
<?php echo \yii2mod\comments\widgets\Comment::widget([
135+
<?php echo \coderseden\cmt\widgets\Comment::widget([
136136
'model' => $model,
137137
'relatedTo' => 'User ' . \Yii::$app->user->identity->username . ' commented on the page ' . \yii\helpers\Url::current(),
138138
'maxLevel' => 2,
@@ -154,10 +154,10 @@ You may use the following events:
154154
```php
155155
'modules' => [
156156
'comment' => [
157-
'class' => 'yii2mod\comments\Module',
157+
'class' => 'coderseden\cmt\Module',
158158
'controllerMap' => [
159159
'default' => [
160-
'class' => 'yii2mod\comments\controllers\DefaultController',
160+
'class' => 'coderseden\cmt\controllers\DefaultController',
161161
'on beforeCreate' => function ($event) {
162162
$event->getCommentModel();
163163
// your custom code

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"autoload": {
3333
"psr-4": {
34-
"yii2mod\\comments\\": ""
34+
"coderseden\\cmt\\": ""
3535
}
3636
},
3737
"repositories": [

controllers/DefaultController.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace yii2mod\comments\controllers;
3+
namespace coderseden\cmt\controllers;
44

55
use Yii;
66
use yii\filters\AccessControl;
@@ -11,41 +11,41 @@
1111
use yii\web\NotFoundHttpException;
1212
use yii\web\Response;
1313
use yii\widgets\ActiveForm;
14-
use yii2mod\comments\events\CommentEvent;
15-
use yii2mod\comments\models\CommentModel;
16-
use yii2mod\comments\traits\ModuleTrait;
14+
use coderseden\cmt\events\CommentEvent;
15+
use coderseden\cmt\models\CommentModel;
16+
use coderseden\cmt\traits\ModuleTrait;
1717
use yii2mod\editable\EditableAction;
1818

1919
/**
2020
* Class DefaultController
2121
*
22-
* @package yii2mod\comments\controllers
22+
* @package coderseden\cmt\controllers
2323
*/
2424
class DefaultController extends Controller
2525
{
2626
use ModuleTrait;
2727

2828
/**
2929
* Event is triggered before creating a new comment.
30-
* Triggered with yii2mod\comments\events\CommentEvent
30+
* Triggered with coderseden\cmt\events\CommentEvent
3131
*/
3232
const EVENT_BEFORE_CREATE = 'beforeCreate';
3333

3434
/**
3535
* Event is triggered after creating a new comment.
36-
* Triggered with yii2mod\comments\events\CommentEvent
36+
* Triggered with coderseden\cmt\events\CommentEvent
3737
*/
3838
const EVENT_AFTER_CREATE = 'afterCreate';
3939

4040
/**
4141
* Event is triggered before deleting the comment.
42-
* Triggered with yii2mod\comments\events\CommentEvent
42+
* Triggered with coderseden\cmt\events\CommentEvent
4343
*/
4444
const EVENT_BEFORE_DELETE = 'beforeDelete';
4545

4646
/**
4747
* Event is triggered after deleting the comment.
48-
* Triggered with yii2mod\comments\events\CommentEvent
48+
* Triggered with coderseden\cmt\events\CommentEvent
4949
*/
5050
const EVENT_AFTER_DELETE = 'afterDelete';
5151

@@ -109,9 +109,7 @@ public function actionCreate($entity)
109109
$event = Yii::createObject(['class' => CommentEvent::class, 'commentModel' => $commentModel]);
110110
$commentModel->setAttributes($this->getCommentAttributesFromEntity($entity));
111111
$this->trigger(self::EVENT_BEFORE_CREATE, $event);
112-
113112
if ($commentModel->load(Yii::$app->request->post()) && $commentModel->saveComment()) {
114-
115113
$this->trigger(self::EVENT_AFTER_CREATE, $event);
116114

117115
return ['status' => 'success'];

controllers/ManageController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22

3-
namespace yii2mod\comments\controllers;
3+
namespace coderseden\cmt\controllers;
44

55
use Yii;
66
use yii\web\Controller;
77
use yii\web\NotFoundHttpException;
8-
use yii2mod\comments\models\CommentModel;
9-
use yii2mod\comments\traits\ModuleTrait;
8+
use coderseden\cmt\models\CommentModel;
9+
use coderseden\cmt\traits\ModuleTrait;
1010

1111
/**
1212
* Class ManageController
1313
*
14-
* @package yii2mod\comments\controllers
14+
* @package coderseden\cmt\controllers
1515
*/
1616
class ManageController extends Controller
1717
{
@@ -20,17 +20,17 @@ class ManageController extends Controller
2020
/**
2121
* @var string path to index view file, which is used in admin panel
2222
*/
23-
public $indexView = '@vendor/yii2mod/yii2-comments/views/manage/index';
23+
public $indexView = '@vendor/coderseden/cmt/views/manage/index';
2424

2525
/**
2626
* @var string path to update view file, which is used in admin panel
2727
*/
28-
public $updateView = '@vendor/yii2mod/yii2-comments/views/manage/update';
28+
public $updateView = '@vendor/coderseden/cmt/views/manage/update';
2929

3030
/**
3131
* @var string search class name for searching
3232
*/
33-
public $searchClass = 'yii2mod\comments\models\search\CommentSearch';
33+
public $searchClass = 'coderseden\cmt\models\search\CommentSearch';
3434

3535
/**
3636
* @var array verb filter config

events/CommentEvent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
namespace yii2mod\comments\events;
3+
namespace coderseden\cmt\events;
44

55
use yii\base\Event;
6-
use yii2mod\comments\models\CommentModel;
6+
use coderseden\cmt\models\CommentModel;
77

88
/**
99
* Class CommentEvent
1010
*
11-
* @package yii2mod\comments\events
11+
* @package coderseden\cmt\events
1212
*/
1313
class CommentEvent extends Event
1414
{

models/CommentModel.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22

3-
namespace yii2mod\comments\models;
3+
namespace coderseden\cmt\models;
44

55
use paulzi\adjacencyList\AdjacencyListBehavior;
66
use Yii;
7-
use yii2mod\comments\behaviors\BlameableBehavior;
7+
use yii\behaviors\BlameableBehavior;
88
use yii\behaviors\TimestampBehavior;
99
use yii\db\ActiveQuery;
1010
use yii\db\ActiveRecord;
1111
use yii\helpers\ArrayHelper;
1212
use yii2mod\behaviors\PurifyBehavior;
13-
use yii2mod\comments\traits\ModuleTrait;
13+
use coderseden\cmt\traits\ModuleTrait;
1414
use yii2mod\moderation\enums\Status;
1515
use yii2mod\moderation\ModerationBehavior;
1616
use yii2mod\moderation\ModerationQuery;
@@ -220,9 +220,6 @@ public function saveComment()
220220
*/
221221
public function getAuthor()
222222
{
223-
if (app()->getModule('comment')->params['commentsIdentityPrimaryId']) {
224-
return $this->hasOne($this->getModule()->userIdentityClass, [app()->getModule('comment')->params['commentsIdentityPrimaryId'] => 'createdBy']);
225-
}
226223
return $this->hasOne($this->getModule()->userIdentityClass, ['id' => 'createdBy']);
227224
}
228225

models/search/CommentSearch.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
namespace yii2mod\comments\models\search;
3+
namespace coderseden\cmt\models\search;
44

55
use yii\data\ActiveDataProvider;
6-
use yii2mod\comments\models\CommentModel;
6+
use coderseden\cmt\models\CommentModel;
77

88
/**
99
* Class CommentSearch
1010
*
11-
* @package yii2mod\comments\models\search
11+
* @package coderseden\cmt\models\search
1212
*/
1313
class CommentSearch extends CommentModel
1414
{

traits/ModuleTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
namespace yii2mod\comments\traits;
3+
namespace coderseden\cmt\traits;
44

55
use Yii;
6-
use yii2mod\comments\Module;
6+
use coderseden\cmt\Module;
77

88
/**
99
* Class ModuleTrait
1010
*
11-
* @package yii2mod\comments\traits
11+
* @package coderseden\cmt\traits
1212
*/
1313
trait ModuleTrait
1414
{

0 commit comments

Comments
 (0)