public function PdfFormat::__construct in Printer and PDF versions for Drupal 8+ 8
Same name and namespace in other branches
- 2.x modules/printable_pdf/src/Plugin/PrintableFormat/PdfFormat.php \Drupal\printable_pdf\Plugin\PrintableFormat\PdfFormat::__construct()
Parameters
array $configuration: The configuration array.
string $plugin_id: The plugin id.
array $plugin_definition: The plugin definition.
\Drupal\Core\Config\ConfigFactory $config_factory: The config factory service.
\Drupal\pdf_api\PdfGeneratorPluginManager $pdf_generator_manager: The PDF generator plugin manager service.
\Drupal\printable\PrintableCssIncludeInterface $printable_css_include: The printable CSS include interface.
\Drupal\printable\LinkExtractor\LinkExtractorInterface $link_extractor: The Link extractor service.
\Drupal\Core\Path\CurrentPathStack $pathCurrent: Represents the current path for the current request.
\Symfony\Component\HttpFoundation\RequestStack $requestStack: Request stack that controls the lifecycle of requests.
Overrides PrintableFormatBase::__construct
File
- modules/
printable_pdf/ src/ Plugin/ PrintableFormat/ PdfFormat.php, line 87
Class
- PdfFormat
- Provides a plugin to display a PDF version of a page.
Namespace
Drupal\printable_pdf\Plugin\PrintableFormatCode
public function __construct(array $configuration, $plugin_id, array $plugin_definition, ConfigFactory $config_factory, PdfGeneratorPluginManager $pdf_generator_manager, PrintableCssIncludeInterface $printable_css_include, LinkExtractorInterface $link_extractor, CurrentPathStack $pathCurrent, RequestStack $requestStack) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $config_factory, $printable_css_include, $link_extractor);
$this->pdfGeneratorManager = $pdf_generator_manager;
$this->pathCurrent = $pathCurrent;
$this->requestStack = $requestStack;
$pdf_library = (string) $this->configFactory
->get('printable.settings')
->get('pdf_tool');
if (!$pdf_library) {
return;
}
$pdf_library = strtolower($pdf_library);
$this->pdfGenerator = $this->pdfGeneratorManager
->createInstance($pdf_library);
if ($pdf_library != 'wkhtmltopdf') {
return;
}
$options = [];
$use_xvfb_run = (string) $this->configFactory
->get('printable.settings')
->get('print_pdf_use_xvfb_run');
$path_to_xfb_run = (string) $this->configFactory
->get('printable.settings')
->get('path_to_xfb_run');
$ignore_warnings = (bool) $this->configFactory
->get('printable.settings')
->get('ignore_warnings');
if ($use_xvfb_run) {
$options = [
'use-xserver' => NULL,
'commandOptions' => [
'enableXvfb' => TRUE,
'xvfbRunBinary' => $path_to_xfb_run,
],
'ignoreWarnings' => $ignore_warnings,
];
}
$this->pdfGenerator
->getObject()
->setOptions($options);
}