How can I disable the Gedmo/Loggable event on Address

Viewed 20

I'm using Sylius and I want to disable the log of address change witch is done by gedmo/loggable.

This is added in the Address.orm.xml from the AddressingBundle here :

<gedmo:loggable log-entry-class="Sylius\Component\Addressing\Model\AddressLogEntry"/>

We have no use of it and the table entries go wild pretty quickly. (More than a million in half a year)

Is there any way to remove the annotation or the event ? I've tried to create a listener on LoadClassMetadataEventArgs to remove it from the doctrine metadata but it's not here.

PS: For information, I'm using sylius 1.10.13 and Gedmo 3.2.0.

EDIT: I found a way to remove the eventListener but I don't like the solution since it disable all the possible loggable from Gedmo and not only for the Address :

    public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
    {
        foreach ($eventArgs->getEntityManager()->getEventManager()->getListeners("postPersist") as $listener) {
            if (get_class($listener) === LoggableListener::class) {
                $eventArgs->getEntityManager()->getEventManager()->removeEventListener(['postPersist, onFlush'], $listener);
            }
        }
    }
0 Answers
Related