You are here

function getTheRightDisplay in Form Mode Control 8

If the user does'nt has the permission to a form mode, he redirected to the default form mode configured in the configure page.

The configuration

Parameters

$configuration:

$mode:

$id_role:

$context:

Return value

string

1 call to getTheRightDisplay()
controlAccessFormMode in ./form_mode_control.module

File

./form_mode_control.module, line 190

Code

function getTheRightDisplay($configuration, $mode, $id_role, $context) {
  $extractConfigFormStates = extractConfigFormStates($configuration, $mode, $id_role);
  foreach ($extractConfigFormStates as $form_state_key => $form_mode_id) {
    $display_name = explode(".", $form_mode_id)[2];
    $config = explode('_', $form_state_key);

    // Extract the default form mode configured in the page of the
    // configuration
    $role = $config[1];
    $entity_type = $config[2];
    $bundle = $config[3];
    if ($context['entity_type'] == $entity_type && $context['bundle'] == $bundle && $id_role == $role) {

      // verify if the configuration(entity type and the bundle)  is the same

      //as the configuration  loaded with context variable, so we extract

      // the right display.
      $id = $context['entity_type'] . '.' . $context['bundle'] . '.' . $display_name;
      return $id;
    }
  }
}