Passed
Push — master ( 35a3f9...fd0cb1 )
by vistart
06:04
created

ViewMembersAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 5
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 22 3
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.me/
9
 * @copyright Copyright (c) 2016 - 2017 vistart
10
 * @license https://vistart.me/license/
11
 */
12
13
namespace rhosocial\organization\web\user\controllers\organization;
14
15
use rhosocial\organization\Organization;
16
use Yii;
17
use yii\base\Action;
18
use yii\data\ActiveDataProvider;
19
use yii\web\BadRequestHttpException;
20
21
/**
22
 * @version 1.0
23
 * @author vistart <[email protected]>
24
 */
25
class ViewMembersAction extends Action
26
{
27
    /**
28
     * 
29
     * @param Organization|string|integer $organization
30
     * @return string rendering result.
31
     */
32
    public function run($organization)
33
    {
34
        if (empty($organization) || ($organization = $this->controller->getOrganization($organization)) == null) {
35
            throw new BadRequestHttpException(Yii::t('organization', 'Organization/Department Not Exist.'));
36
        }
37
        $dataProvider = new ActiveDataProvider([
38
            'query' => $organization->getMembers(),
39
            'pagination' => [
40
                'pageParam' => 'organization-member-page',
41
                'pageSize' => 20,
42
            ],
43
            'sort' => [
44
                'sortParam' => 'organization-member-sort',
45
            ],
46
        ]);
47
        $viewBasePath = $this->controller->viewBasePath;
48
        return $this->controller->render($viewBasePath . 'view-members', [
49
            'user' => Yii::$app->user->identity,
50
            'organization' => $organization,
51
            'dataProvider' => $dataProvider
52
        ]);
53
    }
54
}
55