You are here

public function ParagraphsFrontendUIController::accessUp in Paragraphs frontend ui 8

Same name and namespace in other branches
  1. 8.2 src/Controller/ParagraphsFrontendUIController.php \Drupal\paragraphs_frontend_ui\Controller\ParagraphsFrontendUIController::accessUp()

Check if this is the first paragraph in an entity, if not, deny access.

1 string reference to 'ParagraphsFrontendUIController::accessUp'
paragraphs_frontend_ui.routing.yml in ./paragraphs_frontend_ui.routing.yml
paragraphs_frontend_ui.routing.yml

File

src/Controller/ParagraphsFrontendUIController.php, line 106

Class

ParagraphsFrontendUIController
Controller for up and down actions.

Namespace

Drupal\paragraphs_frontend_ui\Controller

Code

public function accessUp($paragraph) {
  $paragraph = Paragraph::load($paragraph);
  extract($this
    ->getParentData($paragraph));
  $paragraph_items = $parent->{$parent_field_name}
    ->getValue();
  if ($paragraph_items[0]['target_id'] == $paragraph
    ->id()) {
    return AccessResult::forbidden();
  }
  else {
    return AccessResult::allowed();
  }
}