From 2ec967b9735064f114541ce93c88799409c28bcf Mon Sep 17 00:00:00 2001 From: maciekpaprocki Date: Thu, 29 Apr 2021 13:15:15 +0100 Subject: [PATCH] Update custom listener documentation The current doc is a bit outdated. You need to implement the right interface to tell the system which hook should be run. Hopefully, that will help someone in the future trying to figure out why their listener is not working. --- docs/custom_listener.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/custom_listener.md b/docs/custom_listener.md index 37e306a..4dc89ee 100644 --- a/docs/custom_listener.md +++ b/docs/custom_listener.md @@ -12,7 +12,7 @@ use Sylius\Bundle\FixturesBundle\Listener\BeforeSuiteListenerInterface; use Sylius\Bundle\FixturesBundle\Listener\SuiteEvent; use Symfony\Component\Filesystem\Filesystem; -final class DirectoryPurgerListener extends AbstractListener implements ListenerInterface +final class DirectoryPurgerListener extends AbstractListener implements BeforeSuiteListenerInterface { public function getName(): string { @@ -26,7 +26,13 @@ final class DirectoryPurgerListener extends AbstractListener implements Listener } ``` -The next step is to register this listener: +If you want to listen to different/more event(s) instead of BeforeSuiteListenerInterface implement one or more of those interfaces: +- AfterFixtureListenerInterface +- AfterSuiteListenerInterface +- BeforeFixtureListenerInterface +- BeforeSuiteListenerInterface + +The next step is to register this listener ( you can avoid this step when using autoconfiguration ): ```xml