public function TfaEnabledField::render in Two-factor Authentication (TFA) 8
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides Boolean::render
File
- src/
Plugin/ views/ field/ TfaEnabledField.php, line 56
Class
- TfaEnabledField
- Provides a views field to show if the selected user has enabled TFA.
Namespace
Drupal\tfa\Plugin\views\fieldCode
public function render(ResultRow $values) {
$uid = $this
->getValue($values);
$data = $this->userData
->get('tfa', $uid, 'tfa_user_settings');
$value = $data['saved'] ?? FALSE;
if ($this->options['type'] == 'custom') {
$custom_value = $value ? $this->options['type_custom_true'] : $this->options['type_custom_false'];
return ViewsRenderPipelineMarkup::create(UtilityXss::filterAdmin($custom_value));
}
elseif (isset($this->formats[$this->options['type']])) {
return $value ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1];
}
else {
return $value ? $this->formats['yes-no'][0] : $this->formats['yes-no'][1];
}
}