PHP Class FactoryGirl\Provider\Doctrine\FixtureFactory

See the README file for a tutorial.
Afficher le fichier Open project: breerly/factory-girl-php Class Usage Examples

Protected Properties

Свойство Type Description
$em Doctrine\ORM\EntityManager
$entityDefs array
$entityNamespace string
$persist boolean
$singletons array

Méthodes publiques

Méthode Description
__construct ( EntityManager $em )
defineEntity ( $name, array $fieldDefs = [], array $config = [] ) : FixtureFactory Defines how to create a default entity of type $name.
get ( $name, array $fieldOverrides = [] ) Get an entity and its dependencies.
getAsSingleton ( $name, array $fieldOverrides = [] ) A shorthand combining get() and setSingleton().
getEntityNamespace ( )
getList ( $name, array $fieldOverrides = [], $numberOfInstances = 1 ) Get an array of entities and their dependencies.
persistOnGet ( $enabled = true ) Sets whether get() should automatically persist the entity it creates.
setEntityNamespace ( $namespace ) Sets the namespace to be prefixed to all entity names passed to this class.
setSingleton ( $name, $entity ) Sets $entity to be the singleton for $name.
unsetSingleton ( $name ) Unsets the singleton for $name.

Méthodes protégées

Méthode Description
addNamespace ( string $name ) : string
checkFieldOverrides ( EntityDef $def, array $fieldOverrides )
createCollectionFrom ( $array = [] )
setField ( $ent, EntityDef $def, $fieldName, $fieldValue )
updateCollectionSideOfAssocation ( $entityBeingCreated, $metadata, $fieldName, $value )

Method Details

__construct() public méthode

public __construct ( EntityManager $em )
$em Doctrine\ORM\EntityManager

addNamespace() protected méthode

protected addNamespace ( string $name ) : string
$name string
Résultat string

checkFieldOverrides() protected méthode

protected checkFieldOverrides ( EntityDef $def, array $fieldOverrides )
$def EntityDef
$fieldOverrides array

createCollectionFrom() protected méthode

protected createCollectionFrom ( $array = [] )

defineEntity() public méthode

See the readme for a tutorial.
public defineEntity ( $name, array $fieldDefs = [], array $config = [] ) : FixtureFactory
$fieldDefs array
$config array
Résultat FixtureFactory

get() public méthode

Whether the entity is new or not depends on whether you've created a singleton with the entity name. See getAsSingleton(). If you've called persistOnGet() then the entity is also persisted.
public get ( $name, array $fieldOverrides = [] )
$fieldOverrides array

getAsSingleton() public méthode

It's illegal to call this if $name already has a singleton.
public getAsSingleton ( $name, array $fieldOverrides = [] )
$fieldOverrides array

getEntityNamespace() public méthode

public getEntityNamespace ( )

getList() public méthode

Whether the entities are new or not depends on whether you've created a singleton with the entity name. See getAsSingleton(). If you've called persistOnGet() then the entities are also persisted.
public getList ( $name, array $fieldOverrides = [], $numberOfInstances = 1 )
$fieldOverrides array

persistOnGet() public méthode

By default it does not. In any case, you still need to call flush() yourself.
public persistOnGet ( $enabled = true )

setEntityNamespace() public méthode

Sets the namespace to be prefixed to all entity names passed to this class.
public setEntityNamespace ( $namespace )

setField() protected méthode

protected setField ( $ent, EntityDef $def, $fieldName, $fieldValue )
$def EntityDef

setSingleton() public méthode

This causes get($name) to return $entity.
public setSingleton ( $name, $entity )

unsetSingleton() public méthode

This causes get($name) to return new entities again.
public unsetSingleton ( $name )

updateCollectionSideOfAssocation() protected méthode

protected updateCollectionSideOfAssocation ( $entityBeingCreated, $metadata, $fieldName, $value )

Property Details

$em protected_oe property

protected EntityManager,Doctrine\ORM $em
Résultat Doctrine\ORM\EntityManager

$entityDefs protected_oe property

protected array $entityDefs
Résultat array

$entityNamespace protected_oe property

protected string $entityNamespace
Résultat string

$persist protected_oe property

protected bool $persist
Résultat boolean

$singletons protected_oe property

protected array $singletons
Résultat array