Conditions | 3 |
Paths | 3 |
Total Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
27 | public static function handle(SetElementTableAttributeHtmlEvent $event) |
||
28 | { |
||
29 | if ($event->attribute === 'state') { |
||
30 | /** @var User $element */ |
||
31 | $element = $event->sender; |
||
32 | |||
33 | $params = [ |
||
34 | 'indicator' => '', |
||
35 | 'label' => 'N/A' |
||
36 | ]; |
||
37 | |||
38 | $organizaiton = Craft::$app->getRequest()->getParam('organization'); |
||
39 | $state = Organizations::getInstance()->getSettings()->getUserStates(); |
||
40 | |||
41 | if ($association = UserAssociation::findOne([ |
||
42 | 'user' => $element, |
||
43 | 'organization' => $organizaiton |
||
44 | ])) { |
||
45 | $params = [ |
||
46 | 'indicator' => $association->state, |
||
47 | 'label' => $state[$association->state] ?? 'N/A' |
||
48 | ]; |
||
49 | } |
||
50 | |||
51 | $event->html = Html::encodeParams( |
||
52 | '<span class="user-state status {indicator}"></span>{label}', |
||
53 | $params |
||
54 | ); |
||
55 | } |
||
56 | } |
||
57 | } |
||
58 |