How to work with Versionable entities with Doctrine2 Extensions?
I'm trying to use Versionable extension from Doctrine2Extensions but I couldn't a way to implement it.
It is mentioned that we need to 'implements' Versionable interface (which is empty by the way)
Requirements of your entities are:
Single Identifier Column (String or Integer)
Entity has to be versioned (using @version annotation)
Implementing Versionable would look like:
namespace MyProject;
use DoctrineExte开发者_运维知识库nsions\Versionable\Versionable;
class BlogPost implements Versionable {
// blog post API
}
From the documentation.
What I don't understand is :
Single Identifier Column (String or Integer) Entity has to be versioned (using @version annotation)
What those both requirements means?
Here my entity:
<?php
namespace Jo\Model;
use DoctrineExtensions\Versionable\Versionable;
/**
* @Entity
*/
class Comment implements Versionable
{
/**
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Column(type="string", length=255)
*/
protected $body;
What are missing to make version works?
Your $id property provides a single identifier.
From my reading of things, you'll also need a $version (or similar) property, which could be an integer or datetime, and it must be annoted with @Version
This (old) blog post may help give you some more insight (but some of it may be out of date)
精彩评论