zicht / versioning-bundle
Zicht Versioning
Requires
- php: >=5.6
- doctrine/common: *@stable
- doctrine/orm: *@stable
- sonata-project/admin-bundle: *
- symfony/console: 2.*
- symfony/http-foundation: 2.*
- symfony/property-access: 2.*
- symfony/security: 2.*
- symfony/serializer: 2.*
- zicht/itertools: 2.*@stable
- zicht/util: 1.*@stable
Requires (Dev)
- behat/behat: ~3.0
- behat/mink: ~1.6
- behat/mink-extension: ~2.1
- phpunit/phpunit: 4.*@stable
- dev-release/1.x
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.9-rc.3
- 1.0.9-rc.2
- 1.0.9-rc.1
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.6-rc.1
- 1.0.5
- 1.0.5-rc.1
- 1.0.4
- 1.0.4-rc.1
- 1.0.3
- 1.0.2
- 1.0.2-rc.1
- 1.0.1
- 1.0.0
- 1.0.0-rc.3
- 1.0.0-rc.2
- 1.0.0-rc.1
- 1.0.0-beta.13
- 1.0.0-beta.12
- 1.0.0-beta.11
- 1.0.0-beta.10
- 1.0.0-beta.9
- 1.0.0-beta.8
- 1.0.0-beta.7
- 1.0.0-beta.6
- 1.0.0-beta.5
- 1.0.0-beta.4
- 1.0.0-beta.3
- 1.0.0-beta.2
- 1.0.0-beta.1
- 1.0.0-alpha.1
This package is auto-updated.
Last update: 2022-10-29 02:39:50 UTC
README
The ZichtVersioningBundle hooks into Doctrine to save versions in a separate entity
called EntityVersion
, keeping track of changes and being able to revert to and
plan future versions.
Implementation notes
Marking versionable behaviour
To make an entity versionable, the entity should implement the interface
VersionableInterface
. For all OneToMany relations, the relation must be marked
cascade={...,"persist"}
and the contained entity must implement the
EmbeddedVersionableInterface
.
The version data that is currently in the entity's table is called the active
version. By setting another version active, the data from the version table
is loaded into the entity and persisted to the database. This makes the
versioning transparent; i.e., other components do not need to know that the
entity is versioned, and can simply query the database directly, since the
active
version is always in the database table.
There is a command to introspect these versions, which can be useful for debugging.
cloning objects
If you want to be able to clone objects, you need to reset the object's id:
public function __clone()
{
$this->id = null;
}
Otherwise, the versioning will mix up the record id references.
Sonata integration
Because the versioned embedded entities do not exist in the database, sonata's
method of referring to objects using their id (in the childId
parameter in the
routes) does not work. For this, the EmbeddedVersionableAdminTrait
is supplied
to override the id()
, update()
and generateObjectUrl()
methods, so the
index rather than the id is used to refer to child objects. These values
are loaded from the parent object in stead of from the
You should use this trait in all admins that are managing entities that
implement the EmbeddedVersionableInterface
, e.g. as such:
class ContentItemDetailAdmin extends Admin
{
use EmbeddedVersionableAdminTrait;
}
Maintainer
- Boudewijn Schoon boudewijn@zicht.nl