Skip to content
Snippets Groups Projects
Commit afe70d4c authored by Project Update Bot's avatar Project Update Bot Committed by Gaurav Kapoor
Browse files

Issue #3296971 by Project Update Bot: Automated Drupal 10 compatibility fixes

parent 4f6609cb
No related branches found
No related tags found
No related merge requests found
name: Documentation generator
description: Allows administrators to generate documentation describing site features.
type: module
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^9.3 || ^10
......@@ -4,7 +4,9 @@ namespace Drupal\documentation_generator\Plugin\DocumentationGeneratorRender;
use Dompdf\Dompdf;
use Drupal\Core\File\Exception\FileException;
use Drupal\file\FileRepositoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\documentation_generator\Plugin\DocumentationGeneratorRenderBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -21,12 +23,26 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class PDF extends DocumentationGeneratorRenderBase implements ContainerFactoryPluginInterface {
/**
* The mpdf.
* The dompdf.
*
* @var \Dompdf\Dompdf
*/
protected $dompdf;
/**
* The form builder.
*
* @var \Drupal\Core\Render\RendererInterface
*/
protected $renderer;
/**
* The file repository.
*
* @var \Drupal\file\FileRepositoryInterface
*/
protected $fileRepository;
/**
* Constructs a new PDF instance.
*
......@@ -37,12 +53,18 @@ class PDF extends DocumentationGeneratorRenderBase implements ContainerFactoryPl
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Dompdf\Dompdf $dompdf
* The mpdf.
* The dompdf.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer.
* @param \Drupal\file\FileRepositoryInterface $file_repository
* The file repository.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, Dompdf $dompdf) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, Dompdf $dompdf, RendererInterface $renderer, FileRepositoryInterface $file_repository) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->dompdf = $dompdf;
$this->renderer = $renderer;
$this->fileRepository = $file_repository;
}
/**
......@@ -53,7 +75,9 @@ class PDF extends DocumentationGeneratorRenderBase implements ContainerFactoryPl
$configuration,
$plugin_id,
$plugin_definition,
$container->get('documentation_generator.dompdf')
$container->get('documentation_generator.dompdf'),
$container->get('renderer'),
$container->get('file.repository')
);
}
......@@ -74,13 +98,13 @@ class PDF extends DocumentationGeneratorRenderBase implements ContainerFactoryPl
'#groups' => $groups,
];
$this->dompdf->loadHtml(render($build));
$this->dompdf->loadHtml($this->renderer->render($build));
$this->dompdf->render();
$output = $this->dompdf->output();
$success = TRUE;
try {
file_save_data($output, 'private://' . $fileName);
$this->fileRepository->writeData($output, 'private://' . $fileName);
}
catch (FileException $e) {
$success = FALSE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment