Skip to content

Fincallorca/DoctrineBehaviorSequenceable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sequenceable behavior extension for Doctrine2

LICENSE Packagist LICENSE https://jquery.com/ https://jquery.com/

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;
}