You are here

private function FieldValueExtension::getParentObjectKey in Twig Field Value 8

Same name and namespace in other branches
  1. 2.0.x src/Twig/Extension/FieldValueExtension.php \Drupal\twig_field_value\Twig\Extension\FieldValueExtension::getParentObjectKey()

Determine the build array key of the parent object.

Different field types use different key names.

Parameters

array $build: Render array.

Return value

string The key.

1 call to FieldValueExtension::getParentObjectKey()
FieldValueExtension::getTargetEntity in src/Twig/Extension/FieldValueExtension.php
Twig filter callback: Return the referenced entity.

File

src/Twig/Extension/FieldValueExtension.php, line 185

Class

FieldValueExtension
Provides field value filters for Twig templates.

Namespace

Drupal\twig_field_value\Twig\Extension

Code

private function getParentObjectKey(array $build) {
  $options = [
    '#object',
    '#field_collection_item',
  ];
  $parent_key = '';
  foreach ($options as $option) {
    if (isset($build[$option])) {
      $parent_key = $option;
      break;
    }
  }
  return $parent_key;
}