You are here

protected function DefaultMenuLinkContentReferenceHandler::loadReferencedEntityFromFieldValue in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Plugin/cms_content_sync/field_handler/DefaultMenuLinkContentReferenceHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultMenuLinkContentReferenceHandler::loadReferencedEntityFromFieldValue()
  2. 2.0.x src/Plugin/cms_content_sync/field_handler/DefaultMenuLinkContentReferenceHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler\DefaultMenuLinkContentReferenceHandler::loadReferencedEntityFromFieldValue()

Load the referenced entity, given the $entity->field_* value.

Parameters

$value:

Return value

null|\Drupal\Core\Entity\EntityInterface

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

Overrides EntityReferenceHandlerBase::loadReferencedEntityFromFieldValue

File

src/Plugin/cms_content_sync/field_handler/DefaultMenuLinkContentReferenceHandler.php, line 38

Class

DefaultMenuLinkContentReferenceHandler
Reference menu references and make sure they're published as the content comes available.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\field_handler

Code

protected function loadReferencedEntityFromFieldValue($value) {
  if (empty($value) || empty($value['value'])) {
    return null;
  }
  list($entity_type, $uuid) = explode(':', $value['value']);
  if ('menu_link_content' != $entity_type || empty($uuid)) {
    return null;
  }
  return \Drupal::service('entity.repository')
    ->loadEntityByUuid('menu_link_content', $uuid);
}