You are here

public static function FillPdf::embedView in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x src/Component/Utility/FillPdf.php \Drupal\fillpdf\Component\Utility\FillPdf::embedView()

Correctly embed a View with arguments.

Views_embed_view() does not zero-index.

Parameters

string $name: Name of the view to embed.

string $display_id: (optional) The display ID. Defaults to 'default'.

Return value

array|null A renderable array containing the view output or NULL if the display ID of the view to be executed doesn't exist.

See also

views_embed_view()

1 call to FillPdf::embedView()
FillPdfFormForm::form in src/Form/FillPdfFormForm.php
Gets the actual form array to be built.

File

src/Component/Utility/FillPdf.php, line 58

Class

FillPdf
Class FillPdf.

Namespace

Drupal\fillpdf\Component\Utility

Code

public static function embedView($name, $display_id = 'default') {
  $args = func_get_args();

  // Remove $name and $display_id from the arguments.
  unset($args[0], $args[1]);
  $args = array_values($args);
  $view = Views::getView($name);
  if (!$view || !$view
    ->access($display_id)) {
    return NULL;
  }
  return $view
    ->preview($display_id, $args);
}