class FallbackFieldUnserializer in Acquia Content Hub 8.2
Generic field unserializer fallback subscriber.
Hierarchy
- class \Drupal\acquia_contenthub\EventSubscriber\UnserializeContentField\FallbackFieldUnserializer implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of FallbackFieldUnserializer
1 string reference to 'FallbackFieldUnserializer'
1 service uses FallbackFieldUnserializer
File
- src/
EventSubscriber/ UnserializeContentField/ FallbackFieldUnserializer.php, line 12
Namespace
Drupal\acquia_contenthub\EventSubscriber\UnserializeContentFieldView source
class FallbackFieldUnserializer implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[AcquiaContentHubEvents::UNSERIALIZE_CONTENT_ENTITY_FIELD] = [
'onUnserializeContentField',
];
return $events;
}
/**
* Naive handling for fields that don't have special handling.
*
* @param \Drupal\acquia_contenthub\Event\UnserializeCdfEntityFieldEvent $event
* The unserialize event.
*/
public function onUnserializeContentField(UnserializeCdfEntityFieldEvent $event) {
$field = $event
->getField();
$values = [];
if (!empty($field['value'])) {
foreach ($field['value'] as $langcode => $value) {
$values[$langcode][$event
->getFieldName()] = $value;
}
$event
->setValue($values);
}
$event
->stopPropagation();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FallbackFieldUnserializer:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
FallbackFieldUnserializer:: |
public | function | Naive handling for fields that don't have special handling. |