PHP Class FactoryGirl\Provider\Doctrine\FixtureFactory

See the README file for a tutorial.
ファイルを表示 Open project: breerly/factory-girl-php Class Usage Examples

Protected Properties

Property Type Description
$em Doctrine\ORM\EntityManager
$entityDefs array
$entityNamespace string
$persist boolean
$singletons array

Public Methods

Method 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.

Protected Methods

Method 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 method

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

addNamespace() protected method

protected addNamespace ( string $name ) : string
$name string
return string

checkFieldOverrides() protected method

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

createCollectionFrom() protected method

protected createCollectionFrom ( $array = [] )

defineEntity() public method

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

get() public method

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 method

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

getEntityNamespace() public method

public getEntityNamespace ( )

getList() public method

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 method

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

setEntityNamespace() public method

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

setField() protected method

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

setSingleton() public method

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

unsetSingleton() public method

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

updateCollectionSideOfAssocation() protected method

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

Property Details

$em protected_oe property

protected EntityManager,Doctrine\ORM $em
return Doctrine\ORM\EntityManager

$entityDefs protected_oe property

protected array $entityDefs
return array

$entityNamespace protected_oe property

protected string $entityNamespace
return string

$persist protected_oe property

protected bool $persist
return boolean

$singletons protected_oe property

protected array $singletons
return array