protected function GDPRController::buildFieldTable in General Data Protection Regulation 8
Same name and namespace in other branches
- 8.2 modules/gdpr_fields/src/Controller/GDPRController.php \Drupal\gdpr_fields\Controller\GDPRController::buildFieldTable()
- 3.0.x modules/gdpr_fields/src/Controller/GDPRController.php \Drupal\gdpr_fields\Controller\GDPRController::buildFieldTable()
Build a table for entity field list.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type id.
string $bundle_id: The entity bundle id.
array $filters: Filters.
Return value
array Renderable array for field list table.
1 call to GDPRController::buildFieldTable()
- GDPRController::fieldsList in modules/
gdpr_fields/ src/ Controller/ GDPRController.php - Lists all fields with GDPR sensitivity.
File
- modules/
gdpr_fields/ src/ Controller/ GDPRController.php, line 140
Class
- GDPRController
- Returns responses for GDPR Field routes.
Namespace
Drupal\gdpr_fields\ControllerCode
protected function buildFieldTable(EntityTypeInterface $entity_type, $bundle_id, array $filters) {
$rows = $this->collector
->listFields($entity_type, $bundle_id, $filters);
if (count($rows) == 0) {
return NULL;
}
// Sort rows by field name.
ksort($rows);
$table = [
'#type' => 'table',
'#header' => [
$this
->t('Name'),
$this
->t('Type'),
$this
->t('Right to access'),
$this
->t('Right to be forgotten'),
$this
->t('Notes'),
'',
],
'#sticky' => TRUE,
];
$i = 0;
foreach ($rows as $row) {
$table[$i]['title'] = [
'#plain_text' => $row['title'],
];
$type_markup = $row['is_id'] || $row['type'] == 'entity_reference' ? "<strong>{$row['type']}</strong>" : $row['type'];
$table[$i]['type'] = [
'#markup' => new FormattableMarkup($type_markup, []),
];
$table[$i]['rta'] = [
'#plain_text' => $row['rta'],
];
$table[$i]['rtf'] = [
'#plain_text' => $row['rtf'],
];
$table[$i]['notes'] = [
'#markup' => empty($row['notes']) ? '' : '<span class="notes" data-icon="?"></span><div>' . $row['notes'] . '</div>',
];
$table[$i]['edit'] = [
'#markup' => !empty($row['edit']) ? $row['edit']
->toString() : '',
];
$i++;
}
return $table;
}