You are here

public function SecondaryContactConnectionPermission::hasRolePermissions in RedHen CRM 8

Determine if the contact execute the operation on the subject entity.

Parameters

\Drupal\Core\Entity\EntityInterface $subject_entity: The entity that is being accessed.

string $operation: The operation that is being performed (view, update, delete, view label).

\Drupal\redhen_contact\Entity\Contact $contact: The Redhen contact object.

Return value

bool True is access is allowed, false if neutral.

Overrides ConnectionPermissionBase::hasRolePermissions

File

modules/redhen_connection/src/Plugin/ConnectionPermission/SecondaryContactConnectionPermission.php, line 59

Class

SecondaryContactConnectionPermission
Provide permission for contacts that share a redhen_connection.

Namespace

Drupal\redhen_connection\Plugin\ConnectionPermission

Code

public function hasRolePermissions(EntityInterface $subject_entity, $operation, Contact $contact) {
  $access = new AccessResultNeutral();
  $influencers = $this
    ->getInfluencers($subject_entity);
  foreach ($influencers as $influencer) {
    $access = $this->redhenConnectionConnections
      ->checkConnectionPermission($contact, $influencer, $operation, $this
      ->getPermissionKey());
    if ($access
      ->isAllowed()) {
      return $access;
    }
  }
  return $access;
}