You are here

function masquerade_entity_operation in Masquerade 8.2

Implements hook_entity_operation().

File

./masquerade.module, line 196
Allows privileged users to masquerade as another user.

Code

function masquerade_entity_operation(EntityInterface $entity) {
  $operations = [];
  if ($entity
    ->getEntityTypeId() === 'user') {
    if (masquerade_target_user_access($entity)) {
      $operations['masquerade'] = [
        'title' => t('Masquerade as'),
        'weight' => 100,
        'url' => $entity
          ->toUrl('masquerade'),
      ];
    }
  }
  return $operations;
}