You are here

protected function Subscribers::isEntityOwner in Message Subscribe 8

Helper method to determine if the given entity belongs to the given user.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check ownership of.

int $uid: The user ID to check for ownership.

Return value

bool Returns TRUE if the entity is owned by the given user ID.

1 call to Subscribers::isEntityOwner()
Subscribers::getSubscribers in src/Subscribers.php
Retrieve a list of subscribers for a given entity.

File

src/Subscribers.php, line 360

Class

Subscribers
A message subscribers service.

Namespace

Drupal\message_subscribe

Code

protected function isEntityOwner(EntityInterface $entity, $uid) {

  // Special handling for entites implementing RevisionLogInterface.
  $is_owner = FALSE;
  if ($entity instanceof RevisionLogInterface) {
    $is_owner = $entity
      ->getRevisionUserId() == $uid;
  }
  elseif ($entity instanceof EntityOwnerInterface) {
    $is_owner = $entity
      ->getOwnerId() == $uid;
  }
  return $is_owner;
}