public function NodeContent::render in Quick Tabs 8.3
Return a render array for an individual tab tat the theme layer to process.
Return value
string @todo test if changing type to array works
Overrides TabTypeBase::render
File
- src/
Plugin/ TabType/ NodeContent.php, line 58
Class
- NodeContent
- Provides a 'node content' tab type.
Namespace
Drupal\quicktabs\Plugin\TabTypeCode
public function render(array $tab) {
$options = $tab['content'][$tab['type']]['options'];
$node = \Drupal::entityTypeManager()
->getStorage('node')
->load($options['nid']);
if ($node !== NULL) {
$access_result = $node
->access('view', \Drupal::currentUser(), TRUE);
// Return empty render array if user doesn't have access.
if ($access_result
->isForbidden()) {
return [];
}
$build = \Drupal::entityTypeManager()
->getViewBuilder('node')
->view($node, $options['view_mode']);
if ($options['hide_title']) {
$build['#node']
->setTitle(NULL);
}
return $build;
}
}