You are here

public function BatEventHandlerValueField::render in Booking and Availability Management Tools for Drupal 8

Renders the field.

Parameters

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides FieldPluginBase::render

File

modules/bat_event/src/Plugin/views/field/BatEventHandlerValueField.php, line 21

Class

BatEventHandlerValueField
Plugin annotation @ViewsField("bat_event_handler_value_field");

Namespace

Drupal\bat_event\Plugin\views\field

Code

public function render(ResultRow $values) {
  $event = $this
    ->getEntity($values);
  $event_type = bat_event_type_load($event
    ->bundle());
  if ($event_type
    ->getFixedEventStates()) {
    $state = $event
      ->get('event_state_reference')->entity;
    return $state
      ->label();
  }
  else {
    $field_name = $event_type->default_event_value_field_ids;
    $elements = $event->{$field_name}
      ->view([
      'label' => 'hidden',
    ]);
    $value = $this
      ->getRenderer()
      ->render($elements);
    return $value;
  }
}