In addition to the DoctrineExtensions library or the Doctrine Behaviors of KNP Labs this Bundle add a sequence behaviour to your entities.
The Sequenceable behavior backups entities on changing. Like other behaviours the bundle works through annotations.
Features:
- Specific annotations for properties
- Compatible with other behaviours (KNP, Gedmo, etc.)
Restrictions:
- tested only with MySQL/MariaDB
- tested only with annotations
composer require fincallorca/doctrine-behaviors "dev-master"
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
return [
// [...]
new Fincallorca\DoctrineBehaviors\SequenceableBundle\SequenceableBundle(),
];
}
// [...]
}
Via the config.yml
doctrine:
orm:
entity_managers:
default:
filters:
sequenceable_filter:
class: Fincallorca\DoctrineBehaviors\SequenceableBundle\EventListener\SequenceableSubscriber
enabled: true
You can use Sequenceable trait for quick when using annotation mapping.
At least one field marked as SequenceableID
is mandatory. The value of this field is the
identifier for the sequence column to search for the amount of already existing backups.
<?php
use Doctrine\ORM\Mapping as ORM;
use Fincallorca\DoctrineBehaviors\SequenceableBundle as SequenceableBehavior;
/**
* @ORM\Entity
* @ORM\Table(name="my_entity")
*/
class MyEntity
{
/**
* Hook sequenceable behavior (adds field sequenceable).
*/
use SequenceableBehavior\Entity\Sequenceable;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(length=128)
* @SequenceableBehavior\Annotation\SequenceableID
*/
private $title;
}