You are here

protected function FieldTemplateProcessor::getContext in UI Patterns 8

Get pattern context.

Return value

array Pattern context.

1 call to FieldTemplateProcessor::getContext()
FieldTemplateProcessor::process in modules/ui_patterns_ds/src/FieldTemplateProcessor.php
Process field template variables.

File

modules/ui_patterns_ds/src/FieldTemplateProcessor.php, line 152

Class

FieldTemplateProcessor
Class FieldTemplateProcessor.

Namespace

Drupal\ui_patterns_ds

Code

protected function getContext() {
  $element = $this->variables['element'];
  $context = [
    'type' => 'ds_field_template',
    'field_name' => $this
      ->getFieldName(),
    'entity_type' => $element['#entity_type'],
    'bundle' => $element['#bundle'],
    'view_mode' => $element['#view_mode'],
    'entity' => NULL,
  ];
  if (isset($element['#object']) && is_object($element['#object']) && $element['#object'] instanceof ContentEntityBase) {
    $context['entity'] = $element['#object'];
  }
  return $context;
}