class ConfigEntityLayoutBuilderHandler in Acquia Content Hub 8.2
Handles config entities for Layout Builder entities.
Hierarchy
- class \Drupal\acquia_contenthub\EventSubscriber\Cdf\ConfigEntityLayoutBuilderHandler implements \Symfony\Component\EventDispatcher\EventSubscriberInterface uses LayoutBuilderDataHandlerTrait
Expanded class hierarchy of ConfigEntityLayoutBuilderHandler
1 string reference to 'ConfigEntityLayoutBuilderHandler'
1 service uses ConfigEntityLayoutBuilderHandler
File
- src/
EventSubscriber/ Cdf/ ConfigEntityLayoutBuilderHandler.php, line 14
Namespace
Drupal\acquia_contenthub\EventSubscriber\CdfView source
class ConfigEntityLayoutBuilderHandler implements EventSubscriberInterface {
use LayoutBuilderDataHandlerTrait;
/**
* ConfigEntityLayoutBuilderHandler 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::PARSE_CDF][] = [
'onParseCdf',
90,
];
return $events;
}
/**
* Handles layout builder data in 3rd party settings on entity_view_displays.
*
* @param \Drupal\acquia_contenthub\Event\ParseCdfEntityEvent $event
* The Parse CDF Entity Event.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function onParseCdf(ParseCdfEntityEvent $event) {
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $entity */
$entity = $event
->getEntity();
if ($entity
->getEntityTypeId() !== 'entity_view_display') {
return;
}
$sections = $entity
->getThirdPartySetting('layout_builder', 'sections', []);
if ($sections) {
$entity
->setThirdPartySetting('layout_builder', 'sections', $this
->unserializeSections($sections));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigEntityLayoutBuilderHandler:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ConfigEntityLayoutBuilderHandler:: |
public | function | Handles layout builder data in 3rd party settings on entity_view_displays. | |
ConfigEntityLayoutBuilderHandler:: |
public | function | ConfigEntityLayoutBuilderHandler 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. |