You are here

class ConfigEntityLayoutBuilderHandler in Acquia Content Hub 8.2

Handles config entities for Layout Builder entities.

Hierarchy

Expanded class hierarchy of ConfigEntityLayoutBuilderHandler

1 string reference to 'ConfigEntityLayoutBuilderHandler'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses ConfigEntityLayoutBuilderHandler
config_entity.layout_builder.cdf.handler in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\EventSubscriber\Cdf\ConfigEntityLayoutBuilderHandler

File

src/EventSubscriber/Cdf/ConfigEntityLayoutBuilderHandler.php, line 14

Namespace

Drupal\acquia_contenthub\EventSubscriber\Cdf
View 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

Namesort descending Modifiers Type Description Overrides
ConfigEntityLayoutBuilderHandler::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ConfigEntityLayoutBuilderHandler::onParseCdf public function Handles layout builder data in 3rd party settings on entity_view_displays.
ConfigEntityLayoutBuilderHandler::__construct public function ConfigEntityLayoutBuilderHandler constructor.
LayoutBuilderDataHandlerTrait::$entityTypeManager protected property The entity type manager. 2
LayoutBuilderDataHandlerTrait::getComponentConfiguration protected function Gets configuration for a Layout Builder component.
LayoutBuilderDataHandlerTrait::serializeComponents protected function Prepares component to be serialized.
LayoutBuilderDataHandlerTrait::serializeSections protected function Prepares Layout Builder sections to be serialized.
LayoutBuilderDataHandlerTrait::unserializeComponents protected function Prepares Layout Builder components to be unserialized.
LayoutBuilderDataHandlerTrait::unserializeSections protected function Prepares Layout Builder sections to be unserialized.