I would like to track changes of different entities and refer to a specific version from other tables. For example: in the Orderline
table, I would like to refer to a specific version of a product.
Is the Loggable
extension the best way to implement this feature or should I manualy add a ProductVersion entity?
I'm using Loggable
at this moment and I think I'm missing a feature like $product->getCurrentVersion()
to get the current version number. Or do I misread the documentation?
You can implement this function in your Repository to get current/last version
public function getCurrentVersion($id)
{
$repo = $this->_em->getRepository('Gedmo\Loggable\Entity\LogEntry');
$log = $repo->findOneBy(array('objectId' =>$id), array('version' => 'desc'));
return $log ? $log->getVersion() : null; // or return $log for entire object
}