You are here

function rac_pa_paragraphs_access_restriction_message_alter in Role Access Control 8

Implements hook_paragraph_access_restriction_message_alter().

File

contrib/rac_pa/rac_pa.module, line 74
Module providing role base access for paragraphs.

Code

function rac_pa_paragraphs_access_restriction_message_alter(ParagraphInterface $paragraph, $op, &$message) {
  $entityRoles = _rac_get_entity_reference_roles($paragraph);
  if (count($entityRoles)) {

    // If entity has roles, then update text to reflex them.
    if (count($entityRoles) > 1) {

      // If there are multiple roles, construct proper english message.
      $last = array_pop($entityRoles);
      $list = implode(", ", $entityRoles) . " or " . $last;
      $message["#markup"] = "Users with the roles " . $list . " may edit this item.";
    }
    elseif (count($entityRoles) > 0) {
      $message["#markup"] = "Users with the role " . $entityRoles[0] . " may edit this item.";
    }
  }
}