EntityAuditBundle
EntityAuditBundle copied to clipboard
Support for translatable entities
Feature Request
The current state of the bundle does not support auditing entities which implement gedmo/knplabs translatable doctrine behaviors. I've started implementing the behavior, but encountered several issues that should be discussed beforehand.
- gedmo and knplabs load necessary locale data when doctrine postLoad event is fired. As audited entities are not loaded by doctrine, this event is never trigged. A solution might be to trigger the event manually, as loading audited entities should in my opinion simulate the same behavior as
$someObjectRepository->find(), but this should be discussed. The code below works as expected
// SimpleThings\EntityAudit\AuditReader
private function createEntity($className, array $columnMap, array $data, $revision){
...
$eventManager = $this->em->getEventManager();
$eventArgs = new LifecycleEventArgs($entity, $this->em);
$eventManager->dispatchEvent(Events::postLoad, $eventArgs);
return $entity;
}
- the class
SimpleThings\EntityAudit\Collection\AuditedCollectionthrows an exception when callingget($key)on a key that does not exist. This causes a failure if trying to fetch a audited translation with a locale that does not exist. The solution would be to return null (which is probably the expected behavior asDoctrine\Common\Collections\ReadableCollectionsuggests a@psalm-return T|null, but again this should be discussed
Before going any further, I would like to know your opinion if such a feature should be implemented. If yes, I would be happy to work on it