You are here

protected function DefaultFieldCollectionHandler::loadReferencedEntity 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::loadReferencedEntity()
  2. 2.0.x src/Plugin/cms_content_sync/field_handler/DefaultFieldCollectionHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultFieldCollectionHandler::loadReferencedEntity()

Load the entity that is either referenced or embedded by $definition.

Parameters

$definition:

Return value

\Drupal\Core\Entity\EntityInterface

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

\Drupal\cms_content_sync\Exception\SyncException

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

Overrides EntityReferenceHandlerBase::loadReferencedEntity

File

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

Class

DefaultFieldCollectionHandler
Providing a minimalistic implementation for any field type.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler

Code

protected function loadReferencedEntity(PullIntent $intent, $definition) {
  $previousFieldHandler = self::$currentFieldHandler;
  $previousPullIntent = self::$currentPullIntent;

  // Expose current field and intent (to reference host entity)
  // As field collections require this when being created.
  self::$currentFieldHandler = $this;
  self::$currentPullIntent = $intent;
  $entity = parent::loadReferencedEntity($intent, $definition);
  self::$currentFieldHandler = $previousFieldHandler;
  self::$currentPullIntent = $previousPullIntent;
  return $entity;
}