Same name and namespace in other branches
  1. 4.x src/Plugin/TabType/NodeContent.php \Drupal\quicktabs\Plugin\TabType\NodeContent::render()

Overrides TabTypeBase::render

File

src/Plugin/TabType/NodeContent.php, line 58

Class

NodeContent
Provides a 'node content' tab type.

Namespace

Drupal\quicktabs\Plugin\TabType

Code

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;
    }
}