-
Notifications
You must be signed in to change notification settings - Fork 3
ManyToMany
This isn't required in the target project at the time of this writing. Where the project was left at SoliantEntityAudit was the author wrestling with how to find these relations and how to audit them. You see, if you have an entity to audit and it has a large many to many relation the Doctrine way to do it is to fetch every entity the table is joined with.
Given entity1 and entity2 there exists a table between them but not an entity. Getting the join information is like
foreach ($entity->getJoinedEntity() as $joinedEntity) {
$auditManyToManyEntity = new RevisionEntity\AuditManyToManyEntity();
$auditManyToManyEntity->setJoinedEntityId($joinedEntity->getId());
$auditManyToManyEntity->setEntityId($entity->getId());
$auditManyToManyEntity->setAuditEntity($auditEntity);
$auditObjectManager->persist($auditManyToManyEntity);
}
I hope this example shows the expense required to audit the many to many relationship. Delta auditing of the many to many relationships is possible but seems like an even less good idea.
This problem of auditing many to many also exists in the SimpleThings EntityAudit
zf-doctrine-audit © 2016 API Skeletons. Released under the MIT license.