class EntityViewDisplaySerializer in Acquia Content Hub 8.2
Serializer for entity view displays.
Hierarchy
- class \Drupal\acquia_contenthub\EventSubscriber\SerializeConfig\EntityViewDisplaySerializer implements \Symfony\Component\EventDispatcher\EventSubscriberInterface uses LayoutBuilderDataHandlerTrait
Expanded class hierarchy of EntityViewDisplaySerializer
1 string reference to 'EntityViewDisplaySerializer'
1 service uses EntityViewDisplaySerializer
File
- src/
EventSubscriber/ SerializeConfig/ EntityViewDisplaySerializer.php, line 14
Namespace
Drupal\acquia_contenthub\EventSubscriber\SerializeConfigView source
class EntityViewDisplaySerializer implements EventSubscriberInterface {
use LayoutBuilderDataHandlerTrait;
/**
* EntityViewDisplaySerializer constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->entityTypeManager = $entityTypeManager;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = [];
$events[AcquiaContentHubEvents::SERIALIZE_CONFIG_ENTITY][] = [
'onSerializeConfigEntity',
100,
];
return $events;
}
/**
* Serializes layout_builder 3rd party settings data on entity_view_displays.
*
* @param \Drupal\acquia_contenthub\Event\ConfigDataEvent $event
* The config data event object.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function onSerializeConfigEntity(ConfigDataEvent $event) {
/** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $entity */
$entity = $event
->getEntity();
if ($entity
->getEntityTypeId() !== 'entity_view_display') {
return;
}
$sections = $entity
->getThirdPartySetting('layout_builder', 'sections') ?? [];
if ($sections) {
$data = $event
->getData();
$data[$entity
->language()
->getId()]['third_party_settings']['layout_builder']['sections'] = $this
->serializeSections(...$sections);
$event
->setData($data);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityViewDisplaySerializer:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
EntityViewDisplaySerializer:: |
public | function | Serializes layout_builder 3rd party settings data on entity_view_displays. | |
EntityViewDisplaySerializer:: |
public | function | EntityViewDisplaySerializer constructor. | |
LayoutBuilderDataHandlerTrait:: |
protected | property | The entity type manager. | 2 |
LayoutBuilderDataHandlerTrait:: |
protected | function | Gets configuration for a Layout Builder component. | |
LayoutBuilderDataHandlerTrait:: |
protected | function | Prepares component to be serialized. | |
LayoutBuilderDataHandlerTrait:: |
protected | function | Prepares Layout Builder sections to be serialized. | |
LayoutBuilderDataHandlerTrait:: |
protected | function | Prepares Layout Builder components to be unserialized. | |
LayoutBuilderDataHandlerTrait:: |
protected | function | Prepares Layout Builder sections to be unserialized. |