Documentation

Populator
in package

Service class for populating a database using the Doctrine ORM or ODM.

A Populator can populate several tables using ActiveRecord classes.

Table of Contents

$batchSize  : int
$entities  : array<string|int, mixed>
$generateId  : array<string|int, mixed>
$generator  : Generator
$manager  : ObjectManager|null
$quantities  : array<string|int, mixed>
__construct()  : mixed
Populator constructor.
addEntity()  : mixed
Add an order for the generation of $number records for $entity.
execute()  : array<string|int, mixed>
Populate the database using all the Entity classes previously added.

Properties

$entities

protected array<string|int, mixed> $entities = []

$generateId

protected array<string|int, mixed> $generateId = []

$manager

protected ObjectManager|null $manager

$quantities

protected array<string|int, mixed> $quantities = []

Methods

__construct()

Populator constructor.

public __construct(Generator $generator[, ObjectManager $manager = null ][, int $batchSize = 1000 ]) : mixed
Parameters
$generator : Generator
$manager : ObjectManager = null
$batchSize : int = 1000
Return values
mixed

addEntity()

Add an order for the generation of $number records for $entity.

public addEntity(mixed $entity, int $number[, mixed $customColumnFormatters = [] ][, mixed $customModifiers = [] ][, mixed $generateId = false ]) : mixed
Parameters
$entity : mixed

A Doctrine classname, or a \Faker\ORM\Doctrine\EntityPopulator instance

$number : int

The number of entities to populate

$customColumnFormatters : mixed = []
$customModifiers : mixed = []
$generateId : mixed = false
Return values
mixed

execute()

Populate the database using all the Entity classes previously added.

public execute([EntityManager|null $entityManager = null ]) : array<string|int, mixed>

Please note that large amounts of data will result in more memory usage since the the Populator will return all newly created primary keys after executing.

Parameters
$entityManager : EntityManager|null = null

A Doctrine connection object

Return values
array<string|int, mixed>

A list of the inserted PKs

Search results