You are here

public static function FaqViewer::viewAnswer in Frequently Asked Questions 8

Helper function to setup the faq answer.

Parameters

array &$data: Array reference to store display data in.

Drupal\node\NodeInterface $node: The node object.

string $back_to_top: An array containing the "back to top" link.

bool $teaser: Whether or not to use teasers.

bool $links: Whether or not to show node links.

7 calls to FaqViewer::viewAnswer()
template_preprocess_faq_category_hide_answer in includes/faq.hide_answer.inc
Create categorized FAQ page if set to show answer when question is clicked.
template_preprocess_faq_category_questions_inline in includes/faq.questions_inline.inc
Create categorized FAQ page if set to show/hide the questions inline.
template_preprocess_faq_category_questions_top in includes/faq.questions_top.inc
Create categorized questions for FAQ page if set to show questions on top.
template_preprocess_faq_category_questions_top_answers in includes/faq.questions_top.inc
Create categorized answers for FAQ page if set to show the questions on top.
template_preprocess_faq_hide_answer in includes/faq.hide_answer.inc
Create FAQ page if set to show/hide answer when question is clicked.

... See full list

File

src/FaqViewer.php, line 86

Class

FaqViewer
Controlls the display of questions and answers.

Namespace

Drupal\faq

Code

public static function viewAnswer(&$data, NodeInterface $node, $teaser) {
  $faq_settings = \Drupal::config('faq.settings');

  // TODO: hide 'submitted by ... on ...'
  $view_mode = $teaser ? 'teaser' : 'full';
  $node_build = \Drupal::entityTypeManager()
    ->getViewBuilder('node')
    ->view($node, $view_mode);
  hide($node_build['title']);
  if (!$faq_settings
    ->get('question_long_form')) {
    hide($node_build['field_detailed_question']);
  }
  $content = \Drupal::service('renderer')
    ->render($node_build);
  $content .= FaqViewer::initBackToTop();
  $data['body'] = new FormattableMarkup($content, []);
}