You are here

public function PreviewLinkStorage::getPreviewLink in Preview Link 8

Gets the preview link given entity type Id and entity Id.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

Return value

\Drupal\preview_link\Entity\PreviewLinkInterface|false The preview link entity if it exists otherwise FALSE.

Overrides PreviewLinkStorageInterface::getPreviewLink

1 call to PreviewLinkStorage::getPreviewLink()
PreviewLinkStorage::getPreviewLinkForEntity in src/PreviewLinkStorage.php
Gets the preview link for a given entity.

File

src/PreviewLinkStorage.php, line 90

Class

PreviewLinkStorage
Preview Link entity storage.

Namespace

Drupal\preview_link

Code

public function getPreviewLink(ContentEntityInterface $entity) {
  $result = $this
    ->loadByProperties([
    'entity_type_id' => $entity
      ->getEntityTypeId(),
    'entity_id' => $entity
      ->id(),
  ]);
  return $result ? array_pop($result) : FALSE;
}