You are here

function paragraphs_previewer_paragraphs_item_access in Paragraphs Previewer 7

Implements hook_paragraphs_item_access().

File

./paragraphs_previewer.module, line 107
Provides a rendered preview of a paragraphs item on an entity form..

Code

function paragraphs_previewer_paragraphs_item_access($entity, $op, $account) {

  // Loosen access on the previewer page to allow rendering new paragraphs and
  // nested new paragraphs from the form state when the paragraphs module
  // cannot determine the host.
  if ($op == 'view' && !empty($entity) && strpos($_GET['q'], 'paragraphs-previewer/') === 0) {

    // If new or no host entity.
    if (empty($entity->item_id) || !$entity
      ->hostEntity()) {
      return PARAGRAPHS_ITEM_ACCESS_ALLOW;
    }
  }
  return PARAGRAPHS_ITEM_ACCESS_IGNORE;
}