You are here

public function ParagraphsFrontendUIController::accessDown in Paragraphs frontend ui 8.2

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

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

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

File

src/Controller/ParagraphsFrontendUIController.php, line 198

Class

ParagraphsFrontendUIController
Controller for up and down actions.

Namespace

Drupal\paragraphs_frontend_ui\Controller

Code

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