xiidea / EasyAuditBundle

A Symfony Bundle To Log Selective Events
http://xiidea.github.io/EasyAuditBundle/
MIT License
89 stars 22 forks source link

How to log the many to many changes #24

Open braianj opened 6 years ago

braianj commented 6 years ago

Hello, for example the changes into rol of a user something like

 /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToMany(targetEntity="LoginBundle\Entity\Roles", inversedBy="usuarios")
     * @ORM\JoinTable(name="user_roles",
     *   joinColumns={
     *     @ORM\JoinColumn(name="id_user", referencedColumnName="id")
     *   },
     *   inverseJoinColumns={
     *     @ORM\JoinColumn(name="id_rol", referencedColumnName="id")
     *   }
     * )
     */
    private $roles;

When I make changes on a rol of a user, there is no print of that instance

ronisaha commented 6 years ago

Modifications to collections are not considered entity modifications. You have to use custom event to track such change. This library do not contain any built in event to track such event.

You can achieve this by accessing with Doctrine\ORM\UnitOfWork#getScheduledCollectionDeletions() and Doctrine\ORM\UnitOfWork#getScheduledCollectionUpdated() Note that this API is ONLY supposed to be used within event listeners attached to the UnitOfWork's lifecycle events.

PR are always welcome.

Thanks.

braianj commented 6 years ago

I want to save inserts no modification. Please see #29