protected function EntityReferenceHandlerBase::serializeReference in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/Plugin/EntityReferenceHandlerBase.php \Drupal\cms_content_sync\Plugin\EntityReferenceHandlerBase::serializeReference()
- 2.0.x src/Plugin/EntityReferenceHandlerBase.php \Drupal\cms_content_sync\Plugin\EntityReferenceHandlerBase::serializeReference()
Parameters
$value:
Return value
array
Throws
\Drupal\Core\Entity\EntityStorageException
\Drupal\cms_content_sync\Exception\SyncException
\GuzzleHttp\Exception\GuzzleException
1 call to EntityReferenceHandlerBase::serializeReference()
2 methods override EntityReferenceHandlerBase::serializeReference()
- DefaultUserReferenceHandler::serializeReference in src/
Plugin/ cms_content_sync/ field_handler/ DefaultUserReferenceHandler.php - DefaultWebformHandler::serializeReference in src/
Plugin/ cms_content_sync/ field_handler/ DefaultWebformHandler.php
File
- src/
Plugin/ EntityReferenceHandlerBase.php, line 501
Class
- EntityReferenceHandlerBase
- Providing a base implementation for any reference field type.
Namespace
Drupal\cms_content_sync\PluginCode
protected function serializeReference(PushIntent $intent, EntityInterface $reference, $value) {
foreach ($this
->getInvalidSubfields() as $field) {
unset($value[$field]);
}
foreach ($value as $key => $data) {
if ('field_' == substr($key, 0, 6)) {
unset($value[$key]);
}
}
// Allow mapping by label.
if ('taxonomy_term' == $reference
->getEntityTypeId()) {
$value[Entity::LABEL_KEY] = $reference
->label();
}
if ($this
->shouldEmbedReferencedEntities()) {
return $intent
->embed($reference, $value);
}
if ($this
->shouldPushReferencedEntities()) {
return $intent
->addDependency($reference, $value);
}
return $intent
->addReference($reference, $value);
}