VAVANG INVOICE / DOCS / EN

Events

Vavang Invoice currently exposes one application event in the initial compliance flow: SyliusInvoicePlugin\Invoice\InvoiceCreated.

Transport

The event is dispatched through sylius.event_bus, which is injected as a Symfony Messenger MessageBusInterface. It is not dispatched through Symfony EventDispatcherInterface.

The payload contains:

  • SourceInvoiceReference, identifying the source Sylius invoice;
  • ActionOrigin, describing whether the action originated from the system or another supported origin.

Do not register a Symfony event subscriber expecting a classic kernel/domain event with this class. Consume it as a message on the Sylius event bus.

Example handler

<?php

declare(strict_types=1);

namespace App\Invoice;

use SyliusInvoicePlugin\Invoice\InvoiceCreated;

final class OnInvoiceCreated
{
    public function __invoke(InvoiceCreated $event): void
    {
        $sourceInvoice = $event->sourceInvoice();
        $origin = $event->origin();

        // Trigger project-specific side effects without mutating the source invoice.
    }
}
# config/services.yaml
services:
    App\Invoice\OnInvoiceCreated:
        tags:
            - { name: messenger.message_handler, bus: sylius.event_bus }

Scope

InvoiceCreated signals the entry into the initial compliance-processing path. It is not a generic notification for every subsequent state change, validation result, transmission result or credit-note action.

If a required event does not exist, do not couple application code to an internal Doctrine listener or private implementation class. Open an extension request or use a documented service decorator where that matches the use case.

BC risk

The message class and its accessors are safer integration points than the concrete dispatcher or Doctrine listener that currently emits it. Treat internal listeners and dispatcher constructors as implementation details.