Same name and namespace in other branches
- 4.x src/Plugin/TabType/NodeContent.php \Drupal\quicktabs\Plugin\TabType\NodeContent::render()
Overrides TabTypeBase::render
Fichier
-
src/
Plugin/ TabType/ NodeContent.php, line 58
Classe
- 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;
}
}