You are here

public function DefaultContentEntityHandler::getViewUrl in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 2.0.x src/Plugin/cms_content_sync/entity_handler/DefaultContentEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultContentEntityHandler::getViewUrl()

Parameters

\Drupal\cms_content_sync\PushIntent $intent:

Return value

string

Throws

\Drupal\cms_content_sync\Exception\SyncException

Overrides EntityHandlerBase::getViewUrl

File

src/Plugin/cms_content_sync/entity_handler/DefaultContentEntityHandler.php, line 70

Class

DefaultContentEntityHandler
Class DefaultContentEntityHandler, providing a minimalistic implementation for any content entity type.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler

Code

public function getViewUrl(EntityInterface $entity) {
  if ('paragraph' === $entity
    ->getEntityTypeId()) {
    $parent = $entity;
    do {
      $parent = $parent
        ->getParentEntity();
    } while ($parent && 'paragraph' === $parent
      ->getEntityTypeId());
    if (!$parent) {
      throw new \Exception("Paragraphs can't be syndicated without being embedded in Content Sync v2.");
    }
    return parent::getViewUrl($parent);
  }
  return parent::getViewUrl($entity);
}