You are here

public function FieldValueExtension::getFieldLabel 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::getFieldLabel()

Twig filter callback: Only return a field's label.

Parameters

array|null $build: Render array of a field.

Return value

string The label of a field. If $build is not a render array of a field, NULL is returned.

File

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

Class

FieldValueExtension
Provides field value filters for Twig templates.

Namespace

Drupal\twig_field_value\Twig\Extension

Code

public function getFieldLabel($build) {
  if (!$this
    ->isFieldRenderArray($build)) {
    return NULL;
  }
  return isset($build['#title']) ? $build['#title'] : NULL;
}