You are here

protected function EntityHandlerBase::setSourceUrl in CMS Content Sync 8

Throws

\Drupal\cms_content_sync\Exception\SyncException

1 call to EntityHandlerBase::setSourceUrl()
EntityHandlerBase::push in src/Plugin/EntityHandlerBase.php

File

src/Plugin/EntityHandlerBase.php, line 709

Class

EntityHandlerBase
Common base class for entity handler plugins.

Namespace

Drupal\cms_content_sync\Plugin

Code

protected function setSourceUrl(PushIntent $intent, EntityInterface $entity) {
  if ($entity
    ->hasLinkTemplate('canonical')) {
    try {
      $url = $entity
        ->toUrl('canonical', [
        'absolute' => true,
      ])
        ->toString(true)
        ->getGeneratedUrl();
      $intent
        ->getOperation()
        ->setSourceDeepLink($url, $intent
        ->getActiveLanguage());
    } catch (\Exception $e) {
      throw new SyncException(SyncException::CODE_UNEXPECTED_EXCEPTION, $e);
    }
  }
}