You are here

private function RightToBeForgottenEntityTraversal::getAnonymizerId in General Data Protection Regulation 8.2

Same name and namespace in other branches
  1. 8 modules/gdpr_tasks/src/Traversal/RightToBeForgottenEntityTraversal.php \Drupal\gdpr_tasks\Traversal\RightToBeForgottenEntityTraversal::getAnonymizerId()
  2. 3.0.x modules/gdpr_tasks/src/Traversal/RightToBeForgottenEntityTraversal.php \Drupal\gdpr_tasks\Traversal\RightToBeForgottenEntityTraversal::getAnonymizerId()

Gets the ID of the anonymizer plugin to use on this field.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.

\Drupal\gdpr_fields\Entity\GdprField $field_config: GDPR field configuration.

Return value

string The anonymizer ID or null.

1 call to RightToBeForgottenEntityTraversal::getAnonymizerId()
RightToBeForgottenEntityTraversal::anonymize in modules/gdpr_tasks/src/Traversal/RightToBeForgottenEntityTraversal.php
Runs anonymize functionality against a field.

File

modules/gdpr_tasks/src/Traversal/RightToBeForgottenEntityTraversal.php, line 243

Class

RightToBeForgottenEntityTraversal
Entity traversal used for Right to be Forgotten requests.

Namespace

Drupal\gdpr_tasks\Traversal

Code

private function getAnonymizerId(FieldDefinitionInterface $field_definition, GdprField $field_config) {
  $anonymizer = $field_config->anonymizer;
  $type = $field_definition
    ->getType();
  if (!$anonymizer) {

    // No anonymizer defined directly on the field.
    // Instead try and get one for the datatype.
    $anonymizers = [
      'string' => 'gdpr_text_anonymizer',
      'datetime' => 'gdpr_date_anonymizer',
    ];
    $this->moduleHandler
      ->alter('gdpr_type_anonymizers', $anonymizers);
    $anonymizer = $anonymizers[$type];
  }
  return $anonymizer;
}