1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Itstructure\UsersModule\controllers; |
4
|
|
|
|
5
|
|
|
use yii\base\InvalidConfigException; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class ProfileController |
9
|
|
|
* ProfileController implements the CRUD actions for identityClass. |
10
|
|
|
* |
11
|
|
|
* @package Itstructure\UsersModule\controllers |
12
|
|
|
*/ |
13
|
|
|
class ProfileController extends BaseController |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Initialize. |
17
|
|
|
* Set validateComponent and additionFields. |
18
|
|
|
*/ |
19
|
|
|
public function init() |
20
|
|
|
{ |
21
|
|
|
$this->viewPath = '@users/views/profile'; |
22
|
|
|
|
23
|
|
|
$this->validateComponent = $this->module->get('profile-validate-component'); |
|
|
|
|
24
|
|
|
|
25
|
|
|
parent::init(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Returns addition fields. |
30
|
|
|
* @return array |
31
|
|
|
*/ |
32
|
|
|
protected function getAdditionFields(): array |
33
|
|
|
{ |
34
|
|
|
$additionFields = []; |
35
|
|
|
|
36
|
|
|
$additionFields['customRewrite'] = $this->validateComponent->getCustomRewrite(); |
|
|
|
|
37
|
|
|
|
38
|
|
|
if ($this->action->id == 'create' || $this->action->id == 'update'){ |
39
|
|
|
$additionFields['additionFields'] = $this->validateComponent->getFormFields(); |
|
|
|
|
40
|
|
|
|
41
|
|
|
$additionTemplate = $this->validateComponent->getFormTemplate(); |
|
|
|
|
42
|
|
|
if (is_callable($additionTemplate)){ |
43
|
|
|
$additionTemplate = call_user_func($additionTemplate, $this->getModel()); |
44
|
|
|
} |
45
|
|
|
if (is_string($additionTemplate)){ |
46
|
|
|
$this->additionFields['additionTemplate'] = $additionTemplate; |
47
|
|
|
} else { |
48
|
|
|
throw new InvalidConfigException('Addition template as a result be a string.'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
if ($this->validateComponent->getRbacManage()){ |
|
|
|
|
52
|
|
|
$additionFields['roles'] = $this->validateComponent->getAuthManager()->getRoles(); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
if ($this->action->id == 'index'){ |
57
|
|
|
$additionFields['indexViewColumns'] = $this->validateComponent->getIndexViewColumns(); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if ($this->action->id == 'view'){ |
61
|
|
|
$additionFields['detailViewAttributes'] = $this->validateComponent->getDetailViewAttributes(); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return $additionFields; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Returns identityClass model name. |
69
|
|
|
* |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
protected function getModelName():string |
73
|
|
|
{ |
74
|
|
|
return \Yii::$app->user->identityClass; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Returns identityClass Search model name. |
79
|
|
|
* |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
protected function getSearchModelName():string |
83
|
|
|
{ |
84
|
|
|
return \Yii::$app->user->identityClass . 'Search'; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.