protected function RightToAccessEntityTraversal::processEntity in General Data Protection Regulation 3.0.x
Same name and namespace in other branches
- 8.2 modules/gdpr_tasks/src/Traversal/RightToAccessEntityTraversal.php \Drupal\gdpr_tasks\Traversal\RightToAccessEntityTraversal::processEntity()
- 8 modules/gdpr_tasks/src/Traversal/RightToAccessEntityTraversal.php \Drupal\gdpr_tasks\Traversal\RightToAccessEntityTraversal::processEntity()
Handles the entity.
By default this just returns the entity instance, but derived classes should override this method if they need to collect additional data on the instance.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity to handle.
\Drupal\gdpr_fields\Entity\GdprFieldConfigEntity $config: GDPR config for this entity.
string $row_id: Row identifier used in SARs.
\Drupal\gdpr_fields\Entity\GdprField|null $parent_config: Parent's config.
Overrides EntityTraversal::processEntity
File
- modules/
gdpr_tasks/ src/ Traversal/ RightToAccessEntityTraversal.php, line 32
Class
- RightToAccessEntityTraversal
- Entity traversal for performing Right to Access requests.
Namespace
Drupal\gdpr_tasks\TraversalCode
protected function processEntity(FieldableEntityInterface $entity, GdprFieldConfigEntity $config, $row_id, GdprField $parent_config = NULL) {
$entityType = $entity
->getEntityTypeId();
$fields = $this->entityFieldManager
->getFieldDefinitions($entityType, $entity
->bundle());
$fieldConfigs = $config
->getFieldsForBundle($entity
->bundle());
foreach ($fields as $fieldId => $field) {
$fieldConfig = isset($fieldConfigs[$fieldId]) ? $fieldConfigs[$fieldId] : NULL;
// If the field is not configured, not enabled,
// or not enabled for RTA, then skip it.
if ($fieldConfig === NULL || !$fieldConfig->enabled || !in_array($fieldConfig->rta, [
'inc',
'maybe',
])) {
continue;
}
$pluginName = "{$entityType}|{$entity->bundle()}|{$fieldId}";
$filename = 'main';
if ($parent_config) {
$filename = !empty($parent_config->sarsFilename) ? $parent_config->sarsFilename : $filename;
}
$fieldValue = $this
->getFieldValue($entity, $field, $fieldId);
$data = [
'plugin_name' => $pluginName,
'entity_type' => $entityType,
'entity_id' => $entity
->id(),
'file' => $filename,
'row_id' => $row_id,
'label' => $field
->getLabel(),
'value' => $fieldValue,
'notes' => $fieldConfig->notes,
'rta' => $fieldConfig->rta,
];
$this->results["{$pluginName}|{$entity->id()}"] = $data;
}
}