Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php declare(strict_types=1);

namespace App\Dispatcher;

use Ibexa\Bundle\Messenger\Stamp\DeduplicateStamp;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\MessageBusInterface;

final class SomeClassThatSchedulesExecutionInTheBackground
{
private MessageBusInterface $bus;

public function __construct(MessageBusInterface $bus)
{
$this->bus = $bus;
}

public function schedule(object $message): void
{
// Dispatch directly. Message is wrapped with envelope without any stamps.
$this->bus->dispatch($message);

// Alternatively, wrap with stamps. In this case, DeduplicateStamp ensures
// that if similar command exists in the queue (or is being processed)
// it will not be queued again.
$envelope = Envelope::wrap(
$message,
[new DeduplicateStamp('command-name-1')]
);

$this->bus->dispatch($envelope);
}
}
8 changes: 8 additions & 0 deletions code_samples/background_tasks/src/Message/SomeMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php declare(strict_types=1);

namespace App\Message;

class SomeMessage
{
// Add properties and methods as needed for your message.
}
13 changes: 13 additions & 0 deletions code_samples/background_tasks/src/MessageHandler/SomeHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);

namespace App\MessageHandler;

use App\Message\SomeMessage;

final class SomeHandler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-10-01 at 18 07 01

Asking just to be sure: Symfony doc mentions that if you choose to avoid using the Attribute, then the MessageHandlerInterface interface needs to be implemented.

Can we skip it in this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only true for Symfony 5.x. On Symfony 6 and above, that interface does not exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so this is ok for v5, but the interface should be added when backporting to 4.6?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 4.6 MessageHandlerInterface is indeed required. I don't remember if you can create handlers without it, or just tag the service properly. I think it's mostly used to mark service, but unsure.

{
public function __invoke(SomeMessage $message): void
{
// Handle message.
}
}
46 changes: 24 additions & 22 deletions docs/api/event_reference/discounts_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@

## Discount management

The events below are dispatched when managing [discounts](discounts_guide.md):
The events below are dispatched when managing [`discounts`](discounts_guide.md):

| Event | Dispatched by |
|---|---|
|[BeforeCreateDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeCreateDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html) |
|[CreateDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html) |
|[BeforeDeleteDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeDeleteDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html) |
|[DeleteDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-DeleteDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html) |
|[BeforeUpdateDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeUpdateDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html)|
|[UpdateDiscountEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-UpdateDiscountEvent.html)| [DiscountServiceInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html) |
|[`BeforeCreateDiscountEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeCreateDiscountEvent.html)| [`DiscountServiceInterface::createDiscount()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_createDiscount) |

Check failure on line 17 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L17

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 17, "column": 71}}}, "severity": "ERROR"}

Check failure on line 17 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L17

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 17, "column": 222}}}, "severity": "ERROR"}
|[`CreateDiscountEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountEvent.html)| [`DiscountServiceInterface::createDiscount()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_createDiscount) |

Check failure on line 18 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L18

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 18, "column": 65}}}, "severity": "ERROR"}

Check failure on line 18 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L18

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 18, "column": 210}}}, "severity": "ERROR"}
|[`BeforeEnableDiscountEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeEnableDiscountEvent.html)| [`DiscountServiceInterface::enableDiscount()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_enableDiscount) |

Check failure on line 19 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L19

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 19, "column": 71}}}, "severity": "ERROR"}

Check failure on line 19 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L19

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 19, "column": 222}}}, "severity": "ERROR"}
|[`EnableDiscountEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-EnableDiscountEvent.html)| [`DiscountServiceInterface::enableDiscount()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_enableDiscount) |

Check failure on line 20 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L20

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 20, "column": 65}}}, "severity": "ERROR"}

Check failure on line 20 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L20

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 20, "column": 210}}}, "severity": "ERROR"}
|[`BeforeDeleteDiscountEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeDeleteDiscountEvent.html)| [`DiscountServiceInterface::deleteDiscount()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_deleteDiscount) |

Check failure on line 21 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L21

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 21, "column": 71}}}, "severity": "ERROR"}

Check failure on line 21 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L21

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 21, "column": 222}}}, "severity": "ERROR"}
|[`DeleteDiscountEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-DeleteDiscountEvent.html)| [`DiscountServiceInterface::deleteDiscount()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_deleteDiscount) |

Check failure on line 22 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L22

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 22, "column": 65}}}, "severity": "ERROR"}

Check failure on line 22 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L22

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 22, "column": 210}}}, "severity": "ERROR"}
|[`BeforeUpdateDiscountEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-BeforeUpdateDiscountEvent.html)| [`DiscountServiceInterface::updateDiscount()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_updateDiscount) |

Check failure on line 23 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L23

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 23, "column": 71}}}, "severity": "ERROR"}

Check failure on line 23 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L23

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 23, "column": 222}}}, "severity": "ERROR"}
|[`UpdateDiscountEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-UpdateDiscountEvent.html)| [`DiscountServiceInterface::updateDiscount()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountServiceInterface.html#method_updateDiscount) |

Check failure on line 24 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L24

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 24, "column": 65}}}, "severity": "ERROR"}

Check failure on line 24 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L24

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 24, "column": 210}}}, "severity": "ERROR"}

## Form events

Expand All @@ -29,45 +31,45 @@

| Event | Dispatched by |
|---|---|
|[CreateDiscountCreateStructEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountCreateStructEvent.html) | [DiscountFormMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html)|
|[CreateDiscountUpdateStructEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountUpdateStructEvent.html) | [DiscountFormMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html)|
|[CreateFormDataEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateFormDataEvent.html) | [DiscountFormMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html)|
|[MapDiscountToFormDataEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-MapDiscountToFormDataEvent.html) | [DiscountFormMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html) |
|[`CreateDiscountCreateStructEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountCreateStructEvent.html) | [`DiscountFormMapperInterface::mapCreateDataToStruct()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html#method_mapCreateDataToStruct)|

Check failure on line 34 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L34

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 34, "column": 77}}}, "severity": "ERROR"}

Check failure on line 34 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L34

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 34, "column": 245}}}, "severity": "ERROR"}
|[`CreateDiscountUpdateStructEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateDiscountUpdateStructEvent.html) | [`DiscountFormMapperInterface::mapUpdateDataToStruct()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html#method_mapUpdateDataToStruct)|

Check failure on line 35 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L35

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 35, "column": 77}}}, "severity": "ERROR"}

Check failure on line 35 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L35

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 35, "column": 245}}}, "severity": "ERROR"}
|[`CreateFormDataEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-CreateFormDataEvent.html) | [`DiscountFormMapperInterface::createFormData()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html#method_createFormData)|

Check failure on line 36 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L36

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 36, "column": 65}}}, "severity": "ERROR"}

Check failure on line 36 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L36

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 36, "column": 214}}}, "severity": "ERROR"}
|[`MapDiscountToFormDataEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-MapDiscountToFormDataEvent.html) | [`DiscountFormMapperInterface::mapDiscountToFormData()`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-DiscountFormMapperInterface.html#method_mapDiscountToFormData) |

Check failure on line 37 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L37

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 37, "column": 72}}}, "severity": "ERROR"}

Check failure on line 37 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L37

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 37, "column": 235}}}, "severity": "ERROR"}

### Form steps

The following events are dispatched when rendering each step of the discount wizard, allowing you to add new fields to it:

| Event | Event name |
|---|---|
|[CreateFormDataEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-CreateFormDataEvent.html)| `ibexa.discounts.form_mapper.<step_identifier>.create_form_data`|
|[MapCreateDataToStructEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapCreateDataToStructEvent.html)|`ibexa.discounts.form_mapper.<step_identifier>.map_create_data_to_struct`|
|[MapDiscountToFormDataEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapDiscountToFormDataEvent.html)| `ibexa.discounts.form_mapper.<step_identifier>.map_discount_to_form_data`|
|[MapUpdateDataToStructEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapUpdateDataToStructEvent.html)|`ibexa.discounts.form_mapper.<step_identifier>.map_update_data_to_struct `|
|[`CreateFormDataEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-CreateFormDataEvent.html)| `ibexa.discounts.form_mapper.<step_identifier>.create_form_data`|

Check failure on line 45 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L45

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 45, "column": 65}}}, "severity": "ERROR"}
|[`MapCreateDataToStructEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapCreateDataToStructEvent.html)|`ibexa.discounts.form_mapper.<step_identifier>.map_create_data_to_struct`|

Check failure on line 46 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L46

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 46, "column": 72}}}, "severity": "ERROR"}
|[`MapDiscountToFormDataEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapDiscountToFormDataEvent.html)| `ibexa.discounts.form_mapper.<step_identifier>.map_discount_to_form_data`|

Check failure on line 47 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L47

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 47, "column": 72}}}, "severity": "ERROR"}
|[`MapUpdateDataToStructEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Event-Step-MapUpdateDataToStructEvent.html)|`ibexa.discounts.form_mapper.<step_identifier>.map_update_data_to_struct `|

Check failure on line 48 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L48

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 48, "column": 72}}}, "severity": "ERROR"}

The event classes are shared between steps, but they are dispatched with different names.
Each step form mapper dispatches its own set of events.

| Form mapper | Step identifier |
|---|---|
| [ConditionsMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-ConditionsMapperInterface.html)| [`conditions`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-ConditionsInterface.html#constant_IDENTIFIER) |
| [GeneralPropertiesMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-GeneralPropertiesMapperInterface.html)| [`general_properties`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-GeneralPropertiesInterface.html#constant_IDENTIFIER) |
| [ProductConditionsMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-ProductConditionsMapperInterface.html)| [`products`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-ProductConditionInterface.html#constant_IDENTIFIER) |
| [UserConditionsMapperInterface](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-UserConditionsMapperInterface.html)| [`target_group`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-UserConditionInterface.html#constant_IDENTIFIER) |
| [`ConditionsMapperInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-ConditionsMapperInterface.html)| [`conditions`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-ConditionsInterface.html#constant_IDENTIFIER) |

Check failure on line 55 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L55

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 55, "column": 72}}}, "severity": "ERROR"}

Check failure on line 55 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L55

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 55, "column": 202}}}, "severity": "ERROR"}
| [`GeneralPropertiesMapperInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-GeneralPropertiesMapperInterface.html)| [`general_properties`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-GeneralPropertiesInterface.html#constant_IDENTIFIER) |

Check failure on line 56 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L56

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 56, "column": 79}}}, "severity": "ERROR"}

Check failure on line 56 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L56

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 56, "column": 224}}}, "severity": "ERROR"}
| [`ProductConditionsMapperInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-ProductConditionsMapperInterface.html)| [`products`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-ProductConditionInterface.html#constant_IDENTIFIER) |

Check failure on line 57 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L57

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 57, "column": 79}}}, "severity": "ERROR"}

Check failure on line 57 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L57

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 57, "column": 214}}}, "severity": "ERROR"}
| [`UserConditionsMapperInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-FormMapper-UserConditionsMapperInterface.html)| [`target_group`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Data-UserConditionInterface.html#constant_IDENTIFIER) |

Check failure on line 58 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L58

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 58, "column": 76}}}, "severity": "ERROR"}

Check failure on line 58 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L58

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 58, "column": 212}}}, "severity": "ERROR"}

### Back office

These events are dispatched by the back office controllers after user chooses the "Save" action when creating or updating a discount.

| Event | Dispatched by | Description |
|---|---|---|
[PreDiscountCreateEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountCreateEvent.html) | `Ibexa\Bundle\Discounts\Controller\DiscountCreateController` | Dispatched when the discount creation is finished in the back office form |
[PreDiscountUpdateEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountUpdateEvent.html) | `Ibexa\Bundle\Discounts\Controller\DiscountEditController` | Dispatched when the discount modifications is finished in the back office form |
|[`PreDiscountCreateEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountCreateEvent.html) | `Ibexa\Bundle\Discounts\Controller\DiscountCreateController` | Dispatched when the discount creation is finished in the back office form |

Check failure on line 66 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L66

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 66, "column": 68}}}, "severity": "ERROR"}
|[`PreDiscountUpdateEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Discounts-Admin-Form-Event-PreDiscountUpdateEvent.html) | `Ibexa\Bundle\Discounts\Controller\DiscountEditController` | Dispatched when the discount modifications is finished in the back office form |

Check failure on line 67 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L67

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 67, "column": 68}}}, "severity": "ERROR"}

## Discount codes

The event below allows you to inject your custom logic before the discount code is applied to a product in cart:

| Event | Dispatched by | Description |
|---|---|---|
|[BeforeDiscountCodeApplyEvent](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Event-BeforeDiscountCodeApplyEvent.html)|`Ibexa\Bundle\DiscountsCodes\Controller\REST\DiscountCodeController`| Dispatched before a discount code is applied in the cart |
|[`BeforeDiscountCodeApplyEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-DiscountsCodes-Event-BeforeDiscountCodeApplyEvent.html)|`Ibexa\Bundle\DiscountsCodes\Controller\REST\DiscountCodeController`| Dispatched before a discount code is applied in the cart |

Check failure on line 75 in docs/api/event_reference/discounts_events.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/api/event_reference/discounts_events.md#L75

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/api/event_reference/discounts_events.md", "range": {"start": {"line": 75, "column": 74}}}, "severity": "ERROR"}
29 changes: 29 additions & 0 deletions docs/discounts/configure_discounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ ibexa:
products_list_per_page_limit: 15
```

## Discount re-indexing

Discounts feature uses [[= product_name_base =]] Messenger to reindex discounts and product prices as [background tasks](background_tasks.md).
This way changes are processed efficiently without slowing down the system and disrupting the user experience.

When triggered periodically, the `ibexa:discounts:reindex` command identifies discounts that require re-indexing, ensuring prices always remain up-to-date.
If there are edits to discounts that should result in changed product catalog prices, messages are dispatched to the [[= product_name_base =]] Messenger's queue and consumed by a background worker.
The worker passes the messages to the handler, which then starts the re-indexing process at the most convenient moment.

To run discount re-indexing in the background:

1\. Make sure that the transport layer is [defined properly](background_tasks.md#configure-package) in [[= product_name_base =]] Messenger configuration.

2\. Make sure that the [worker starts](background_tasks.md#start-worker) together with the application to watch the transport bus:

``` bash
php bin/console messenger:consume ibexa.messenger.transport --bus=ibexa.messenger.bus
```

3\. Use a scheduler of your choice, for example, [cron](https://en.wikipedia.org/wiki/Cron), to periodically run the following command:

``` bash
php bin/console ibexa:discounts:reindex
```

!!! note "Deploying Symfony Messenger"

For more information about deploying the Messenger to production, see [Symfony documentation]([[= symfony_doc =]]/messenger.html#deploying-to-production).

## Rate limiting

To prevent malicious actors from trying all the possible discount code combinations using brute-force attacks, the [`/discounts_codes/{cartIdentifier}/apply` endpoint](/api/rest_api/rest_api_reference/rest_api_reference.html#discount-codes-apply-discount-to-cart) is rate limited using the [Rate Limiter Symfony component]([[= symfony_doc =]]/rate_limiter.html).
Expand Down
9 changes: 9 additions & 0 deletions docs/discounts/discounts_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@
- limited use: every customer can use the code a specified number of times
- unlimited

### Discount re-indexing

Discounts affect the prices shown in the product catalog.
When a discount is created, updated, or expires, the product catalog must be re-indexed to ensure that the search results and product listings display correct prices.

Check warning on line 119 in docs/discounts/discounts_guide.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/discounts/discounts_guide.md#L119

[Ibexa.OxfordComma] Use a comma before the last 'and' or 'or' in a list of four or more items.
Raw output
{"message": "[Ibexa.OxfordComma] Use a comma before the last 'and' or 'or' in a list of four or more items.", "location": {"path": "docs/discounts/discounts_guide.md", "range": {"start": {"line": 119, "column": 1}}}, "severity": "WARNING"}

To prevent performance disruptions which could occur if re-indexing occurred immediately, [[= product_name =]] uses the [[= product_name_base =]] Messenger's [background queue](background_tasks.md) to process re-indexing tasks in the background.

By [configuring the process](configure_discounts.md#discount-re-indexing), you ensure that re-indexing is performed at the most convenient time to maintain your application's overall stability.

## Capabilities

### Management
Expand Down
4 changes: 4 additions & 0 deletions docs/getting_started/install_ibexa_dxp.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ Finally, remove the temporary file:

To make use of the [Link Manager](url_management.md#enabling-automatic-url-validation).

### Enable discount re-indexing [[% include 'snippets/commerce_badge.md' %]]

Enable [discount re-indexing in the background](configure_discounts.md#discount-re-indexing).

## [[= product_name_cloud =]]

If you want to host your application on [[= product_name_cloud =]], follow the [Ibexa Cloud](install_on_ibexa_cloud.md) procedure.
Loading
Loading