|
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
|
|
|
* |
|
31
|
|
|
* @throws InvalidConfigException |
|
32
|
|
|
* |
|
33
|
|
|
* @return array |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function getAdditionFields(): array |
|
36
|
|
|
{ |
|
37
|
|
|
$additionFields = []; |
|
38
|
|
|
|
|
39
|
|
|
$additionFields['customRewrite'] = $this->validateComponent->getCustomRewrite(); |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
if ($this->action->id == 'create' || $this->action->id == 'update'){ |
|
42
|
|
|
$additionFields['additionFields'] = $this->validateComponent->getFormFields(); |
|
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
$additionTemplate = $this->validateComponent->getFormTemplate(); |
|
|
|
|
|
|
45
|
|
|
if (is_callable($additionTemplate)){ |
|
46
|
|
|
$additionTemplate = call_user_func($additionTemplate, $this->getModel()); |
|
47
|
|
|
} |
|
48
|
|
|
if (is_string($additionTemplate)){ |
|
49
|
|
|
$additionFields['additionTemplate'] = $additionTemplate; |
|
50
|
|
|
} else { |
|
51
|
|
|
throw new InvalidConfigException('Addition template as a result be a string.'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if ($this->validateComponent->getRbacManage()){ |
|
|
|
|
|
|
55
|
|
|
$additionFields['roles'] = $this->validateComponent->getAuthManager()->getRoles(); |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
if ($this->action->id == 'index'){ |
|
60
|
|
|
$additionFields['indexViewColumns'] = $this->validateComponent->getIndexViewColumns(); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
if ($this->action->id == 'view'){ |
|
64
|
|
|
$additionFields['detailViewAttributes'] = $this->validateComponent->getDetailViewAttributes(); |
|
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return $additionFields; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Returns identityClass model name. |
|
72
|
|
|
* |
|
73
|
|
|
* @return string |
|
74
|
|
|
*/ |
|
75
|
|
|
protected function getModelName():string |
|
76
|
|
|
{ |
|
77
|
|
|
return \Yii::$app->user->identityClass; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Returns identityClass Search model name. |
|
82
|
|
|
* |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
|
|
protected function getSearchModelName():string |
|
86
|
|
|
{ |
|
87
|
|
|
return \Yii::$app->user->identityClass . 'Search'; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
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@propertyannotation 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.