SequenceGenerator
extends AbstractIdGenerator
in package
implements
Serializable
Represents an ID generator that uses a database sequence.
Table of Contents
Interfaces
- Serializable
Properties
- $allocationSize : int
- The allocation size of the sequence.
- $alreadyDelegatedToGenerateId : bool
- $maxValue : int|null
- $nextValue : int
- $sequenceName : string
- The name of the sequence.
Methods
- __construct() : mixed
- Initializes a new sequence generator.
- __serialize() : array<string, mixed>
- __unserialize() : void
- generate() : mixed
- Generates an identifier for an entity.
- generateId() : mixed
- Generates an identifier for an entity.
- getCurrentMaxValue() : int|null
- Gets the maximum value of the currently allocated bag of values.
- getNextValue() : int
- Gets the next value that will be returned by generate().
- isPostInsertGenerator() : bool
- Gets whether this generator is a post-insert generator which means that {@link generateId()} must be called after the entity has been inserted into the database.
- serialize() : string
- unserialize() : void
Properties
$allocationSize
The allocation size of the sequence.
private
int
$allocationSize
$alreadyDelegatedToGenerateId
private
bool
$alreadyDelegatedToGenerateId
= false
$maxValue
private
int|null
$maxValue
= null
$nextValue
private
int
$nextValue
= 0
$sequenceName
The name of the sequence.
private
string
$sequenceName
Methods
__construct()
Initializes a new sequence generator.
public
__construct(string $sequenceName, int $allocationSize) : mixed
Parameters
- $sequenceName : string
-
The name of the sequence.
- $allocationSize : int
-
The allocation size of the sequence.
__serialize()
public
__serialize() : array<string, mixed>
Return values
array<string, mixed>__unserialize()
public
__unserialize(array<string, mixed> $data) : void
Parameters
- $data : array<string, mixed>
generate()
Generates an identifier for an entity.
public
generate(EntityManager $em, object|null $entity) : mixed
Parameters
- $em : EntityManager
- $entity : object|null
Tags
generateId()
Generates an identifier for an entity.
public
generateId(EntityManagerInterface $em, mixed $entity) : mixed
Parameters
- $em : EntityManagerInterface
- $entity : mixed
getCurrentMaxValue()
Gets the maximum value of the currently allocated bag of values.
public
getCurrentMaxValue() : int|null
Return values
int|nullgetNextValue()
Gets the next value that will be returned by generate().
public
getNextValue() : int
Return values
intisPostInsertGenerator()
Gets whether this generator is a post-insert generator which means that {@link generateId()} must be called after the entity has been inserted into the database.
public
isPostInsertGenerator() : bool
By default, this method returns FALSE. Generators that have this requirement must override this method and return TRUE.
Return values
boolserialize()
public
serialize() : string
Tags
Return values
stringunserialize()
public
unserialize(string $serialized) : void
Parameters
- $serialized : string