You are here

public function PreviewLinkHost::hasPreviewLinks in Preview Link 2.x

Same name and namespace in other branches
  1. 2.0.x src/PreviewLinkHost.php \Drupal\preview_link\PreviewLinkHost::hasPreviewLinks()

Determines if an entity has any active preview links.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An entity.

Return value

bool Whether the entity has any associated preview links.

Overrides PreviewLinkHostInterface::hasPreviewLinks

File

src/PreviewLinkHost.php, line 59

Class

PreviewLinkHost
Service for relationships between preview links and entities they unlock.

Namespace

Drupal\preview_link

Code

public function hasPreviewLinks(EntityInterface $entity) : bool {
  $count = $this->previewLinkStorage
    ->getQuery()
    ->condition('entities.target_type', $entity
    ->getEntityTypeId())
    ->condition('entities.target_id', $entity
    ->id())
    ->count()
    ->execute();
  return $count > 0;
}