我想跟踪不同实体的变化,并从其他表中引用特定版本。例如:在 Orderline
表中,我想引用产品的特定版本。
是 Loggable
extension实现此功能的最佳方式还是我应该手动添加 ProductVersion 实体?
此时我正在使用 Loggable
,我想我缺少像 $product->getCurrentVersion()
这样的功能来获取当前版本号。还是我误读了文档?
最佳答案
您可以在您的存储库中实现此功能以获取当前/最新版本
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
}
关于php - 使用 loggable 来引用订单行中的产品版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27601243/