You are here

private function ParagraphsFrontendUIController::getParentData 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::getParentData()

Helper function to get the required data about the parent of the paragraph.

5 calls to ParagraphsFrontendUIController::getParentData()
ParagraphsFrontendUIController::accessDown in src/Controller/ParagraphsFrontendUIController.php
Check if this is the last paragraph in an entity, if not, deny access.
ParagraphsFrontendUIController::accessUp in src/Controller/ParagraphsFrontendUIController.php
Check if this is the first paragraph in an entity, if not, deny access.
ParagraphsFrontendUIController::down in src/Controller/ParagraphsFrontendUIController.php
Shift down a single paragraph.
ParagraphsFrontendUIController::duplicate in src/Controller/ParagraphsFrontendUIController.php
Duplicate a paragraph.
ParagraphsFrontendUIController::up in src/Controller/ParagraphsFrontendUIController.php
Shift up a single paragraph.

File

src/Controller/ParagraphsFrontendUIController.php, line 141

Class

ParagraphsFrontendUIController
Controller for up and down actions.

Namespace

Drupal\paragraphs_frontend_ui\Controller

Code

private function getParentData($paragraph) {
  $parent = $paragraph
    ->getParentEntity()
    ->getTranslation($this
    ->langcode());
  return [
    'parent' => $parent,
    'parent_type' => $parent
      ->getEntityTypeId(),
    'parent_bundle' => $parent
      ->getType(),
    'parent_entity_id' => $parent
      ->id(),
    'parent_field_name' => $paragraph
      ->get('parent_field_name')
      ->getValue()[0]['value'],
  ];
}