Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to log the many to many changes #24

Open
braianj opened this issue Jun 12, 2018 · 2 comments
Open

How to log the many to many changes #24

braianj opened this issue Jun 12, 2018 · 2 comments

Comments

@braianj
Copy link

braianj commented Jun 12, 2018

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
Copy link
Member

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
Copy link
Author

braianj commented Jul 26, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants