You are here

public function PasswordFieldSerializer::onSerializeContentField in Acquia Content Hub 8.2

Manipulate the password properties.

Parameters

\Drupal\acquia_contenthub\Event\SerializeCdfEntityFieldEvent $event: The content entity field serialization event.

Overrides FallbackFieldSerializer::onSerializeContentField

File

src/EventSubscriber/SerializeContentField/PasswordFieldSerializer.php, line 33

Class

PasswordFieldSerializer
Password Field Serializer.

Namespace

Drupal\acquia_contenthub\EventSubscriber\SerializeContentField

Code

public function onSerializeContentField(SerializeCdfEntityFieldEvent $event) {
  if ($event
    ->getField()
    ->getFieldDefinition()
    ->getType() == 'password') {
    parent::onSerializeContentField($event);
    if ($values = $event
      ->getFieldData()) {
      foreach ($values['value'] as $langcode => $value) {
        $values['value'][$langcode]['pre_hashed'] = TRUE;
      }
      $event
        ->setFieldData($values);
      $event
        ->stopPropagation();
    }
  }
}