Skip to content

Commit

Permalink
Merge pull request #2805 from spryker/profuel-patch-4
Browse files Browse the repository at this point in the history
Update listen-to-events.md
  • Loading branch information
andriitserkovnyi committed Sep 12, 2024
2 parents 94d640e + 6939514 commit eef4521
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ class ProductRelationAbstractProductChangeListener extends AbstractPlugin implem

Add this listener to `\Pyz\Zed\Event\EventDependencyProvider::getEventListenerCollection`

Example: `$eventCollection->addListener(ProductEvents::PRODUCT_ABSTRACT_BEFORE_CREATE, new ProductRelationAbstractProductChangeListener())`
Example:
```php
$eventCollection->addListener(ProductEvents::PRODUCT_ABSTRACT_BEFORE_CREATE, new ProductRelationAbstractProductChangeListener())`
```

## Listen to events with a subscriber

Event subscribers are another way to listen to events in the system. The advantage of using event subscribers is that all the listeners reside in the module you want to react to the event. Register a subscriber once in `EventDependencyProvider` and later a listener can be added without touching other modules.

To implement a subscriber, follow these steps:

1. Create an event subscriber class—for example:
1. Create an event subscriber class. Example:

```php
<?php
Expand Down

0 comments on commit eef4521

Please sign in to comment.