function DefaultContentSubscriber::preExport

Same name in this branch
  1. 11.x core/modules/media/src/EventSubscriber/DefaultContentSubscriber.php \Drupal\media\EventSubscriber\DefaultContentSubscriber::preExport()
  2. 11.x core/modules/layout_builder/src/EventSubscriber/DefaultContentSubscriber.php \Drupal\layout_builder\EventSubscriber\DefaultContentSubscriber::preExport()
  3. 11.x core/modules/link/src/EventSubscriber/DefaultContentSubscriber.php \Drupal\link\EventSubscriber\DefaultContentSubscriber::preExport()
  4. 11.x core/modules/path/src/EventSubscriber/DefaultContentSubscriber.php \Drupal\path\EventSubscriber\DefaultContentSubscriber::preExport()

Reacts before an entity is exported.

Parameters

\Drupal\Core\DefaultContent\PreExportEvent $event: The event object.

File

core/modules/content_moderation/src/EventSubscriber/DefaultContentSubscriber.php, line 36

Class

DefaultContentSubscriber
Subscribes to default content-related events.

Namespace

Drupal\content_moderation\EventSubscriber

Code

public function preExport(PreExportEvent $event) : void {
  $entity = $event->entity;
  if ($this->moderationInfo
    ->isModeratedEntityType($entity->getEntityType())) {
    // The moderation_state field is not exported by default, because it is
    // computed, but for default content, we do want to preserve it.
    // @see \Drupal\content_moderation\EntityTypeInfo::entityBaseFieldInfo()
    $event->setExportable('moderation_state', TRUE);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.