# Entity listener config

**URL:** <https://forum.mautic.org/t/entity-listener-config/32129>\
**Category:** Development\
**Tags:** development\
**Created:** [May 22, 2024, 1:36pm UTC](https://forum.mautic.org/t/entity-listener-config/32129 "2024-05-22T13:36:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![miki](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/miki/32/12678_2.png) [@miki](https://forum.mautic.org/u/miki)\
**Post date:** [May 22, 2024, 1:36pm UTC](https://forum.mautic.org/t/entity-listener-config/32129/1 "2024-05-22T13:36:28Z")

</div>

Hi,

I am working on a plugin and I would like to use a Doctrine Entity listener. (When the entity is updated I would like to do something). Making the entity listener is OK, but I don’t know what to put in config.php to make it work.

I tried this:

```auto
'mautic.mbi.doctrine.listener.newmatchlistener' => [
                'class' => 'MauticPlugin\MbiBundle\EventListener\NewMatchListener',
                'tag' => 'doctrine.orm.entity_listener',
                'tagArguments' => [
                    'event' => 'postUpdate',
                    'entity' => '\MauticPlugin\MbiBundle\Entity\NewMatch'
                ],
                'arguments' => [
                    'mautic.lead.model.lead',
                    'mautic.lead.model.list'
                ],
            ],

```

I appreciate your help, thanks in advance!

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [May 22, 2024, 7:46pm UTC](https://forum.mautic.org/t/entity-listener-config/32129/2 "2024-05-22T19:46:57Z")

</div>

You have to dispatch event for this new entity first, only then it makes sense to subscribe to it.

Check how its done here: [mautic/app/bundles/LeadBundle/Model/LeadModel.php at 4014cbab554d80f4769ca1e79c0314b393a02d35 · mautic/mautic · GitHub](https://github.com/mautic/mautic/blob/4014cbab554d80f4769ca1e79c0314b393a02d35/app/bundles/LeadBundle/Model/LeadModel.php#L326)

---

<div class="post-metadata">

**Author:** ![miki](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/miki/32/12678_2.png) [@miki](https://forum.mautic.org/u/miki)\
**Post date:** [May 23, 2024, 6:32am UTC](https://forum.mautic.org/t/entity-listener-config/32129/3 "2024-05-23T06:32:49Z")

</div>

Hi, thanks for your reply.

Normally I would have to dispatch my listener, but since it’s a Doctrine LifecycleEvent, it’s dispatched by Symfony. So in this case I have to only enable the listener. As far as I know…

So, I would like to enable my Doctrine listener via the config.php

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [May 24, 2024, 8:58am UTC](https://forum.mautic.org/t/entity-listener-config/32129/4 "2024-05-24T08:58:20Z")

</div>

I would try to somehow configure that with php code. config.php is mostly “deprecated” in favor of services.php and auto-wiring anyway.
