Completed
Push — master ( d7fe2d...0f3d1f )
by vistart
03:24
created

ProfileFormWidget   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 3
A run() 0 4 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 rhosocial\user\Profile;
16
use yii\base\Widget;
17
18
/**
19
 * @version 1.0
20
 * @author vistart <[email protected]>
21
 */
22
class ProfileFormWidget extends Widget
23
{
24
    /**
25
     * @var Profile 
26
     */
27
    public $model;
28
29
    public function init()
30
    {
31
        if (is_null($this->model) || !($this->model instanceof Profile)) {
32
            $this->model = Yii::$app->user->identity->createProfile(['scenario' => Profile::SCENARIO_UPDATE]);
33
        }
34
    }
35
36
    public function run()
37
    {
38
        return $this->render('profile-form-widget', ['model' => $this->model]);
39
    }
40
}
41