diff --git a/.gitignore b/.gitignore
index 012f2eeb..830c0a03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/var/
/vendor/
/node_modules/
/composer.lock
diff --git a/config/services/generators.xml b/config/services/generators.xml
index cfca0642..87fc6a1f 100644
--- a/config/services/generators.xml
+++ b/config/services/generators.xml
@@ -60,6 +60,7 @@
%sylius_invoicing.pdf_generator.enabled%
+
diff --git a/src/Creator/InvoiceCreator.php b/src/Creator/InvoiceCreator.php
index 15b18b96..3b674275 100644
--- a/src/Creator/InvoiceCreator.php
+++ b/src/Creator/InvoiceCreator.php
@@ -22,6 +22,7 @@
use Sylius\InvoicingPlugin\Generator\InvoiceGeneratorInterface;
use Sylius\InvoicingPlugin\Generator\InvoicePdfFileGeneratorInterface;
use Sylius\InvoicingPlugin\Manager\InvoiceFileManagerInterface;
+use Sylius\InvoicingPlugin\Modifier\InvoiceModifierInterface;
final class InvoiceCreator implements InvoiceCreatorInterface
{
@@ -32,7 +33,17 @@ public function __construct(
private readonly InvoicePdfFileGeneratorInterface $invoicePdfFileGenerator,
private readonly InvoiceFileManagerInterface $invoiceFileManager,
private readonly bool $hasEnabledPdfFileGenerator = true,
+ private readonly ?iterable $invoiceModifiers = null,
) {
+ if (null === $this->invoiceModifiers) {
+ trigger_deprecation(
+ 'sylius/invoicing-plugin',
+ '2.1',
+ 'Not passing a "%s" to "%s" is deprecated and will be required in Sylius Invoicing Plugin 3.0.',
+ InvoiceModifierInterface::class,
+ self::class,
+ );
+ }
}
public function __invoke(string $orderNumber, \DateTimeInterface $dateTime): void
@@ -49,6 +60,12 @@ public function __invoke(string $orderNumber, \DateTimeInterface $dateTime): voi
$invoice = $this->invoiceGenerator->generateForOrder($order, $dateTime);
+ if (null !== $this->invoiceModifiers) {
+ foreach ($this->invoiceModifiers as $modifier) {
+ $invoice = $modifier->modify($invoice);
+ }
+ }
+
if (!$this->hasEnabledPdfFileGenerator) {
$this->invoiceRepository->add($invoice);
diff --git a/src/Modifier/InvoiceModifierInterface.php b/src/Modifier/InvoiceModifierInterface.php
new file mode 100644
index 00000000..dec08c3d
--- /dev/null
+++ b/src/Modifier/InvoiceModifierInterface.php
@@ -0,0 +1,21 @@
+