public function PreviewLinkHost::hasPreviewLinks in Preview Link 2.0.x
Same name and namespace in other branches
- 2.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_linkCode
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;
}