public function RoleExpireDate::preRender in Role Expire 8
Same name and namespace in other branches
- 2.x src/Plugin/views/field/RoleExpireDate.php \Drupal\role_expire\Plugin\views\field\RoleExpireDate::preRender()
inheritdoc}
Overrides FieldPluginBase::preRender
File
- src/
Plugin/ views/ field/ RoleExpireDate.php, line 165
Class
- RoleExpireDate
- Field handler to display the role expire date.
Namespace
Drupal\role_expire\Plugin\views\fieldCode
public function preRender(&$values) {
$this->items = [];
if (is_array($values)) {
$format = $this->options['date_format'];
if (in_array($format, [
'custom',
])) {
$custom_format = $this->options['custom_date_format'];
}
else {
$custom_format = '';
}
$timezone = !empty($this->options['timezone']) ? $this->options['timezone'] : NULL;
foreach ($values as $user) {
$expirations = $this->roleExpireApi
->getAllUserRecords($user->uid);
foreach ($expirations as $role => $timestamp) {
$date = $this->dateFormatter
->format($timestamp, $format, $custom_format, $timezone);
$this->items[$user->uid][$role]['date'] = $date;
}
}
}
}