You are here

public function CalendarEventEmbeddedDisplay::build in Opigno calendar event 8

Same name and namespace in other branches
  1. 3.x src/CalendarEventEmbeddedDisplay.php \Drupal\opigno_calendar_event\CalendarEventEmbeddedDisplay::build()

Builds en embedded calendar event display.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: Field definition.

\Drupal\opigno_calendar_event\CalendarEventInterface[] $calendar_events: Calendar events.

Return value

array Calendar events build.

File

src/CalendarEventEmbeddedDisplay.php, line 51

Class

CalendarEventEmbeddedDisplay
Provides a display to attach a calendar event to an entity.

Namespace

Drupal\opigno_calendar_event

Code

public function build(FieldDefinitionInterface $field_definition, array $calendar_events) {
  $build = [];
  $element =& $build[static::ELEMENT_NAME];
  $element = $this->entityTypeManager
    ->getViewBuilder(CalendarEventInterface::ENTITY_TYPE_ID)
    ->viewMultiple($calendar_events, 'embedded_display');
  $element['#field_name'] = $field_definition
    ->getName();
  $element['#bundle'] = $field_definition
    ->getTargetBundle();
  return $build;
}