Skip to content

Commit 9ae977f

Browse files
committed
OS-110 injecting dependency
1 parent 1599ed0 commit 9ae977f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
services:
22
os2forms_attachment.print_builder:
33
class: Drupal\os2forms_attachment\Os2formsAttachmentPrintBuilder
4-
arguments: ['@entity_print.renderer_factory', '@event_dispatcher', '@string_translation']
4+
arguments: ['@entity_print.renderer_factory', '@event_dispatcher', '@string_translation', '@file_system']

modules/os2forms_attachment/src/Os2formsAttachmentPrintBuilder.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,27 @@
44

55
use Drupal\Core\Entity\EntityInterface;
66
use Drupal\Core\File\FileExists;
7+
use Drupal\Core\File\FileSystemInterface;
8+
use Drupal\Core\StringTranslation\TranslationInterface;
79
use Drupal\entity_print\Event\PreSendPrintEvent;
810
use Drupal\entity_print\Event\PrintEvents;
911
use Drupal\entity_print\Plugin\PrintEngineInterface;
1012
use Drupal\entity_print\PrintBuilder;
13+
use Drupal\entity_print\Renderer\RendererFactoryInterface;
14+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1115

1216
/**
1317
* The OS2Forms attachment print builder service.
1418
*/
1519
class Os2formsAttachmentPrintBuilder extends PrintBuilder {
1620

21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function __construct(RendererFactoryInterface $renderer_factory, EventDispatcherInterface $event_dispatcher, TranslationInterface $string_translation, protected readonly FileSystemInterface $file_system) {
25+
parent::__construct($renderer_factory, $event_dispatcher, $string_translation);
26+
}
27+
1728
/**
1829
* {@inheritdoc}
1930
*/
@@ -55,7 +66,7 @@ public function savePrintableDigitalSignature(array $entities, PrintEngineInterf
5566
$uri = "$scheme://$filename";
5667

5768
// Save the file.
58-
return \Drupal::service('file_system')->saveData($print_engine->getBlob(), $uri, FileExists::Replace);
69+
return $this->file_system->saveData($print_engine->getBlob(), $uri, FileExists::Replace);
5970
}
6071

6172
/**

0 commit comments

Comments
 (0)