class PasswordFieldSerializer in Acquia Content Hub 8.2
Password Field Serializer.
@package Drupal\acquia_contenthub\EventSubscriber\SerializeContentField
Hierarchy
- class \Drupal\acquia_contenthub\EventSubscriber\SerializeContentField\FallbackFieldSerializer implements \Symfony\Component\EventDispatcher\EventSubscriberInterface uses ContentFieldMetadataTrait
- class \Drupal\acquia_contenthub\EventSubscriber\SerializeContentField\PasswordFieldSerializer implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of PasswordFieldSerializer
1 string reference to 'PasswordFieldSerializer'
1 service uses PasswordFieldSerializer
File
- src/
EventSubscriber/ SerializeContentField/ PasswordFieldSerializer.php, line 14
Namespace
Drupal\acquia_contenthub\EventSubscriber\SerializeContentFieldView source
class PasswordFieldSerializer extends FallbackFieldSerializer implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[AcquiaContentHubEvents::SERIALIZE_CONTENT_ENTITY_FIELD][] = [
'onSerializeContentField',
5,
];
return $events;
}
/**
* Manipulate the password properties.
*
* @param \Drupal\acquia_contenthub\Event\SerializeCdfEntityFieldEvent $event
* The content entity field serialization event.
*/
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();
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentFieldMetadataTrait:: |
protected | function | Sets field metadata. | |
PasswordFieldSerializer:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides FallbackFieldSerializer:: |
|
PasswordFieldSerializer:: |
public | function |
Manipulate the password properties. Overrides FallbackFieldSerializer:: |