SymfonyFixturesLoader
extends ContainerAwareLoader
in package
Doctrine data fixtures loader that injects the service container into fixture objects that implement ContainerAwareInterface.
Note: Use of this class requires the Doctrine data fixtures extension, which is a suggested dependency for Symfony.
Table of Contents
- $container : mixed
- $fileExtension : string
- The file extension of fixture files.
- $fixtures : mixed
- Array of fixture object instances to execute.
- $groupsFixtureMapping : array<string, array<string, bool>>
- $loadedFixtures : array<string|int, FixtureInterface>
- $orderedFixtures : mixed
- Array of ordered fixture object instances.
- $orderFixturesByDependencies : bool
- Determines if we must order fixtures by its dependencies
- $orderFixturesByNumber : bool
- Determines if we must order fixtures by number
- __construct() : mixed
- addFixture() : void
- Add a fixture object instance to the loader.
- getFixture() : FixtureInterface
- Get a specific fixture instance
- getFixtures() : array<string|int, FixtureInterface>
- Returns the array of data fixtures to execute.
- hasFixture() : bool
- Has fixture?
- isTransient() : bool
- Check if a given fixture is transient and should not be considered a data fixtures class.
- loadFromDirectory() : array<string|int, mixed>
- Find fixtures classes in a given directory and load them.
- loadFromFile() : array<string|int, mixed>
- Find fixtures classes in a given file and load them.
- createFixture() : FixtureInterface
- Overridden to not allow new fixture classes to be instantiated.
- addGroupsFixtureMapping() : void
- Generates an array of the groups and their fixtures
- getUnsequencedClasses() : array<string|int, mixed>
- loadFromIterator() : array<string|int, mixed>
- Load fixtures from files contained in iterator.
- orderFixturesByDependencies() : void
- Orders fixtures by dependencies
- orderFixturesByNumber() : void
- Orders fixtures by number
- validateDependencies() : void
Properties
$container
private
mixed
$container
$fileExtension
The file extension of fixture files.
private
string
$fileExtension
= '.php'
$fixtures
Array of fixture object instances to execute.
private
mixed
$fixtures
= []
Tags
$groupsFixtureMapping
private
array<string, array<string, bool>>
$groupsFixtureMapping
= []
$loadedFixtures
private
array<string|int, FixtureInterface>
$loadedFixtures
= []
$orderedFixtures
Array of ordered fixture object instances.
private
mixed
$orderedFixtures
= []
Tags
$orderFixturesByDependencies
Determines if we must order fixtures by its dependencies
private
bool
$orderFixturesByDependencies
= false
$orderFixturesByNumber
Determines if we must order fixtures by number
private
bool
$orderFixturesByNumber
= false
Methods
__construct()
public
__construct(ContainerInterface $container) : mixed
Parameters
- $container : ContainerInterface
Return values
mixed —addFixture()
Add a fixture object instance to the loader.
public
addFixture(FixtureInterface $fixture) : void
Parameters
- $fixture : FixtureInterface
Return values
void —getFixture()
Get a specific fixture instance
public
getFixture(string $className) : FixtureInterface
Parameters
- $className : string
Return values
FixtureInterface —getFixtures()
Returns the array of data fixtures to execute.
public
getFixtures([array<string|int, string> $groups = [] ]) : array<string|int, FixtureInterface>
Parameters
- $groups : array<string|int, string> = []
Return values
array<string|int, FixtureInterface> —hasFixture()
Has fixture?
public
hasFixture(FixtureInterface $fixture) : bool
Parameters
- $fixture : FixtureInterface
Return values
bool —isTransient()
Check if a given fixture is transient and should not be considered a data fixtures class.
public
isTransient(mixed $className) : bool
Parameters
- $className : mixed
Tags
Return values
bool —loadFromDirectory()
Find fixtures classes in a given directory and load them.
public
loadFromDirectory(string $dir) : array<string|int, mixed>
Parameters
- $dir : string
-
Directory to find fixture classes in.
Return values
array<string|int, mixed> —$fixtures Array of loaded fixture object instances.
loadFromFile()
Find fixtures classes in a given file and load them.
public
loadFromFile(string $fileName) : array<string|int, mixed>
Parameters
- $fileName : string
-
File to find fixture classes in.
Return values
array<string|int, mixed> —$fixtures Array of loaded fixture object instances.
createFixture()
Overridden to not allow new fixture classes to be instantiated.
protected
createFixture(mixed $class) : FixtureInterface
Parameters
- $class : mixed
Return values
FixtureInterface —addGroupsFixtureMapping()
Generates an array of the groups and their fixtures
private
addGroupsFixtureMapping(string $className, array<string|int, string> $groups) : void
Parameters
- $className : string
- $groups : array<string|int, string>
Return values
void —getUnsequencedClasses()
private
getUnsequencedClasses(array<string|int, mixed> $sequences[, iteratable<string|int, mixed>|null $classes = null ]) : array<string|int, mixed>
Parameters
- $sequences : array<string|int, mixed>
- $classes : iteratable<string|int, mixed>|null = null
Tags
Return values
array<string|int, mixed> —loadFromIterator()
Load fixtures from files contained in iterator.
private
loadFromIterator(Iterator $iterator) : array<string|int, mixed>
Parameters
- $iterator : Iterator
Tags
Return values
array<string|int, mixed> —orderFixturesByDependencies()
Orders fixtures by dependencies
private
orderFixturesByDependencies() : void
Return values
void —orderFixturesByNumber()
Orders fixtures by number
private
orderFixturesByNumber() : void
Tags
Return values
void —validateDependencies()
private
validateDependencies(array<string|int, string> $fixtures, FixtureInterface $fixture) : void
Parameters
- $fixtures : array<string|int, string>
-
An array of fixtures with class names as keys
- $fixture : FixtureInterface