fincallorca / doctrine-behaviors
Doctrine2 behavior Sequenceable trait
This package's canonical repository appears to be gone and the package has been frozen as a result.
0.0.5
2018-02-07 16:10 UTC
Requires
- php: >=5.4
- doctrine/common: >=2.2
- doctrine/orm: ^2.5
- symfony/framework-bundle: ~3.0
Requires (Dev)
README
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
Table of Contents
Integration
Install via Composer
composer require fincallorca/doctrine-behaviors "dev-master"
Add Bundle to Symfony Application
Add the SequenceableBundle
to app/AppKernel.php
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { return [ // [...] new Fincallorca\DoctrineBehaviors\SequenceableBundle\SequenceableBundle(), ]; } // [...] }
Add ORM Filter to Configuration
Via the config.yml
doctrine: orm: entity_managers: default: filters: sequenceable_filter: class: Fincallorca\DoctrineBehaviors\SequenceableBundle\EventListener\SequenceableSubscriber enabled: true
The Basics
Use traits
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; }