You are here

private function GdprFieldSettingsForm::setConfig in General Data Protection Regulation 8.2

Same name and namespace in other branches
  1. 8 modules/gdpr_fields/src/Form/GdprFieldSettingsForm.php \Drupal\gdpr_fields\Form\GdprFieldSettingsForm::setConfig()
  2. 3.0.x modules/gdpr_fields/src/Form/GdprFieldSettingsForm.php \Drupal\gdpr_fields\Form\GdprFieldSettingsForm::setConfig()

Sets the GDPR settings for a field.

Parameters

string $entity_type: Entity type.

string $bundle: Bundle.

string $field_name: Field.

bool $enabled: Whether GDPR is enabled for this field.

string $rta: Right to Access setting.

string $rtf: Right to be forgotten.

string $anonymizer: Anonymizer to use.

string $notes: Notes.

int $relationship: Relationship setting.

string $sars_filename: Filename to store data from this relationship in subject access requests.

Return value

\Drupal\gdpr_fields\Entity\GdprFieldConfigEntity The config entity.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to GdprFieldSettingsForm::setConfig()
GdprFieldSettingsForm::submitForm in modules/gdpr_fields/src/Form/GdprFieldSettingsForm.php

File

modules/gdpr_fields/src/Form/GdprFieldSettingsForm.php, line 116

Class

GdprFieldSettingsForm
GDPR Field settings.

Namespace

Drupal\gdpr_fields\Form

Code

private function setConfig($entity_type, $bundle, $field_name, $enabled, $rta, $rtf, $anonymizer, $notes, $relationship, $sars_filename) {
  $field = new GdprField([
    'bundle' => $bundle,
    'name' => $field_name,
    'entity_type_id' => $entity_type,
  ]);
  $field
    ->setEnabled($enabled)
    ->setRta($rta)
    ->setRtf($rtf)
    ->setAnonymizer($anonymizer)
    ->setNotes($notes)
    ->setRelationship($relationship)
    ->setSarsFilename($sars_filename);
  $storage = $this->entityTypeManager
    ->getStorage('gdpr_fields_config');

  /* @var \Drupal\gdpr_fields\Entity\GdprFieldConfigEntity $config */
  $config = $storage
    ->load($entity_type);
  if (!$config) {
    $config = $storage
      ->create([
      'id' => $entity_type,
    ]);
  }
  $config
    ->setField($field);
  return $config;
}