Skip to content
Snippets Groups Projects
Commit 518000d0 authored by Liam Morland's avatar Liam Morland
Browse files

Issue #3297233: Inject file.repository service into OutputHandler

parent 32328453
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ services: ...@@ -23,7 +23,7 @@ services:
fillpdf.output_handler: fillpdf.output_handler:
class: Drupal\fillpdf\OutputHandler class: Drupal\fillpdf\OutputHandler
arguments: ['@fillpdf.token_resolver', '@logger.channel.fillpdf', '@fillpdf.link_manipulator', '@file_system'] arguments: ['@fillpdf.token_resolver', '@logger.channel.fillpdf', '@fillpdf.link_manipulator', '@file_system', '@file.repository']
logger.channel.fillpdf: logger.channel.fillpdf:
parent: logger.channel_base parent: logger.channel_base
......
...@@ -4,6 +4,7 @@ namespace Drupal\fillpdf; ...@@ -4,6 +4,7 @@ namespace Drupal\fillpdf;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\file\FileRepositoryInterface;
use Drupal\fillpdf\Component\Utility\FillPdf; use Drupal\fillpdf\Component\Utility\FillPdf;
use Drupal\fillpdf\Entity\FillPdfFileContext; use Drupal\fillpdf\Entity\FillPdfFileContext;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
...@@ -46,6 +47,13 @@ class OutputHandler implements OutputHandlerInterface { ...@@ -46,6 +47,13 @@ class OutputHandler implements OutputHandlerInterface {
*/ */
protected $fileSystem; protected $fileSystem;
/**
* The file.repository service.
*
* @var \Drupal\file\FileRepositoryInterface
*/
protected $fileRepository;
/** /**
* OutputHandler constructor. * OutputHandler constructor.
* *
...@@ -57,12 +65,15 @@ class OutputHandler implements OutputHandlerInterface { ...@@ -57,12 +65,15 @@ class OutputHandler implements OutputHandlerInterface {
* The FillPdf link manipulator. * The FillPdf link manipulator.
* @param \Drupal\Core\File\FileSystemInterface $file_system * @param \Drupal\Core\File\FileSystemInterface $file_system
* The file system. * The file system.
* @param \Drupal\file\FileRepositoryInterface $file_repository
* The file.repository service.
*/ */
public function __construct(TokenResolverInterface $token_resolver, LoggerInterface $logger, FillPdfLinkManipulatorInterface $link_manipulator, FileSystemInterface $file_system) { public function __construct(TokenResolverInterface $token_resolver, LoggerInterface $logger, FillPdfLinkManipulatorInterface $link_manipulator, FileSystemInterface $file_system, FileRepositoryInterface $file_repository) {
$this->tokenResolver = $token_resolver; $this->tokenResolver = $token_resolver;
$this->logger = $logger; $this->logger = $logger;
$this->linkManipulator = $link_manipulator; $this->linkManipulator = $link_manipulator;
$this->fileSystem = $file_system; $this->fileSystem = $file_system;
$this->fileRepository = $file_repository;
} }
/** /**
...@@ -98,7 +109,7 @@ class OutputHandler implements OutputHandlerInterface { ...@@ -98,7 +109,7 @@ class OutputHandler implements OutputHandlerInterface {
} }
else { else {
// Full steam ahead! // Full steam ahead!
$saved_file = \Drupal::service('file.repository')->writeData($configuration['data'], "{$resolved_destination_path}/{$configuration['filename']}", FileSystemInterface::EXISTS_RENAME); $saved_file = $this->fileRepository->writeData($configuration['data'], "{$resolved_destination_path}/{$configuration['filename']}", FileSystemInterface::EXISTS_RENAME);
$this->rememberFileContext($saved_file, $configuration['context']); $this->rememberFileContext($saved_file, $configuration['context']);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment