You are here

protected function DefaultFieldCollectionHandler::getFieldValuesForReference in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 8 src/Plugin/cms_content_sync/field_handler/DefaultFieldCollectionHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultFieldCollectionHandler::getFieldValuesForReference()
  2. 2.0.x src/Plugin/cms_content_sync/field_handler/DefaultFieldCollectionHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultFieldCollectionHandler::getFieldValuesForReference()

Parameters

$reference:

\Drupal\cms_content_sync\PullIntent $intent:

Return value

array

Overrides EntityReferenceHandlerBase::getFieldValuesForReference

File

src/Plugin/cms_content_sync/field_handler/DefaultFieldCollectionHandler.php, line 101

Class

DefaultFieldCollectionHandler
Providing a minimalistic implementation for any field type.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler

Code

protected function getFieldValuesForReference($reference, $intent) {
  $entity = $intent
    ->getEntity();
  $reference->host_type = $entity
    ->getEntityTypeId();
  $reference->host_id = $entity
    ->id();
  $reference->host_entity = $entity;
  $reference->field_name = $this->fieldName;
  $reference
    ->save(true);
  return [
    'value' => $reference
      ->id(),
    'revision_id' => $reference
      ->getRevisionId(),
  ];
}