function DefaultContentSubscriber::preExport
Same name in this branch
- 11.x core/modules/media/src/EventSubscriber/DefaultContentSubscriber.php \Drupal\media\EventSubscriber\DefaultContentSubscriber::preExport()
- 11.x core/modules/layout_builder/src/EventSubscriber/DefaultContentSubscriber.php \Drupal\layout_builder\EventSubscriber\DefaultContentSubscriber::preExport()
- 11.x core/modules/content_moderation/src/EventSubscriber/DefaultContentSubscriber.php \Drupal\content_moderation\EventSubscriber\DefaultContentSubscriber::preExport()
- 11.x core/modules/link/src/EventSubscriber/DefaultContentSubscriber.php \Drupal\link\EventSubscriber\DefaultContentSubscriber::preExport()
Reacts before an entity is exported.
Parameters
\Drupal\Core\DefaultContent\PreExportEvent $event: The event object.
File
-
core/
modules/ path/ src/ EventSubscriber/ DefaultContentSubscriber.php, line 37
Class
- DefaultContentSubscriber
- Subscribes to default content-related events.
Namespace
Drupal\path\EventSubscriberCode
public function preExport(PreExportEvent $event) : void {
$event->setCallback('field_item:path', function (PathItem $item) : array {
$values = $item->getValue();
// Never export the path ID; it is recreated on import.
unset($values['pid']);
return $values;
});
// Despite being computed, export path fields anyway because, even though
// they're undergirded by path_alias entities, they're not true entity
// references and therefore aren't portable.
foreach ($this->entityFieldManager
->getFieldMapByFieldType('path') as $path_fields_in_entity_type) {
foreach (array_keys($path_fields_in_entity_type) as $name) {
$event->setExportable($name, TRUE);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.