You are here

public function EntityTypeInfo::grantAccessToFormModeOperation in Form mode manager 8

Same name and namespace in other branches
  1. 8.2 src/EntityTypeInfo.php \Drupal\form_mode_manager\EntityTypeInfo::grantAccessToFormModeOperation()

Evaluate if current user has access to given form mode operations.

Parameters

array $form_mode: Current form mode definition.

\Drupal\Core\Entity\EntityInterface $entity: The entity on which to define an operation.

Return value

bool TRUE if user have access to given form mode, if not FALSE.

See also

entityOperation()

1 call to EntityTypeInfo::grantAccessToFormModeOperation()
EntityTypeInfo::entityOperation in src/EntityTypeInfo.php
Adds Form Mode Manager operations on entity that supports it.

File

src/EntityTypeInfo.php, line 181

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\form_mode_manager

Code

public function grantAccessToFormModeOperation(array $form_mode, EntityInterface $entity) {
  $form_mode_id = $form_mode['id'];
  $form_mode_machine_name = $this->formModeManager
    ->getFormModeMachineName($form_mode_id);
  return $this->formModeManager
    ->isActive($entity
    ->getEntityTypeId(), $entity
    ->bundle(), $form_mode_machine_name) && $this->currentUser
    ->hasPermission("use {$form_mode['id']} form mode");
}