Completed
Push — master ( 22896e...75e918 )
by vistart
03:54
created

UserProfileSearchWidget   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 13 3
A run() 0 8 1
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\user\widgets;
14
15
use yii\base\InvalidConfigException;
16
use yii\base\Widget;
17
18
/**
19
 * @version 1.0
20
 * @author vistart <[email protected]>
21
 */
22
class UserProfileSearchWidget extends Widget
23
{
24
    public $formId = 'user-profile-search-form';
25
    public $formConfig = null;
26
    public $model;
27
    public function init()
28
    {
29
        if ($this->model == null) {
30
            throw new InvalidConfigException("The search model should not be empty.");
31
        }
32
        if ($this->formConfig == null) {
33
            $this->formConfig = [
34
                'id' => $this->formId,
35
                'action' => ['index'],
36
                'method' => 'post',
37
            ];
38
        }
39
    }
40
41
    public function run()
42
    {
43
        return $this->render('user-profile-search', [
44
            'model' => $this->model,
45
            'formId' => $this->formId,
46
            'formConfig' => $this->formConfig
47
        ]);
48
    }
49
}
50