public function viewElements(FieldItemListInterface $items, $langcode) {
$rows = array();
foreach ($items as $item) {
$to = $item->language_to
->label();
$from = $item->language_from
->label();
$row[] = array(
'data' => $from,
'class' => array(
'from-language',
Html::getClass('language-' . $from),
),
);
$row[] = array(
'data' => $to,
'class' => array(
'to-language',
Html::getClass('language-' . $to),
),
);
$rows[] = array(
'data' => $row,
'class' => array(
Html::getClass($from . '-' . $to),
),
);
}
return array(
'#theme' => 'table',
'#header' => array(
t('From'),
t('To'),
),
'#rows' => $rows,
);
}