PHP 클래스 League\FactoryMuffin\FactoryMuffin

저자: Graham Campbell ([email protected])
저자: Scott Robertson ([email protected])
저자: Patrick McCarren ([email protected])
저자: Zizaco ([email protected])
파일 보기 프로젝트 열기: zizaco/factory-muff 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$factory League\FactoryMuffin\Generators\GeneratorFactory The generator factory instance.
$store League\FactoryMuffin\Stores\StoreInterface The store instance.

공개 메소드들

메소드 설명
__construct ( League\FactoryMuffin\Stores\StoreInterface $store = null, GeneratorFactory $factory = null ) : void Create a new factory muffin instance.
camelize ( string $str ) : string Camelize string.
create ( string $name, array $attr = [] ) : object Creates and saves a model.
define ( string $name ) : League\FactoryMuffin\Definition Define a new model definition.
deleteSaved ( ) : FactoryMuffin Delete all the saved models.
getDefinition ( string $name ) : League\FactoryMuffin\Definition Get a model definition.
getDefinitions ( ) : League\FactoryMuffin\Definition[] Get all defined model definitions.
instance ( string $name, array $attr = [] ) : object Return an instance of the model.
isPendingOrSaved ( object $model ) : boolean Is the object saved or will be saved?
loadFactories ( string | string[] $paths ) : FactoryMuffin Load the specified factories.
seed ( integer $times, string $name, array $attr = [] ) : object[] Creates and saves multiple versions of a model.

보호된 메소드들

메소드 설명
generate ( object $model, array $attr = [] ) : void Generate and set the model attributes.
make ( string $name, array $attr, boolean $save ) : object Make an instance of a model.
makeClass ( string $class, callable $maker = null ) : object Make an instance of a class.
triggerCallback ( object $model, string $name ) : boolean Trigger the callback if we have one.

비공개 메소드들

메소드 설명
loadDirectory ( string $path ) : void Load all the files in a directory.

메소드 상세

__construct() 공개 메소드

Create a new factory muffin instance.
public __construct ( League\FactoryMuffin\Stores\StoreInterface $store = null, GeneratorFactory $factory = null ) : void
$store League\FactoryMuffin\Stores\StoreInterface The store instance.
$factory League\FactoryMuffin\Generators\GeneratorFactory The generator factory instance.
리턴 void

camelize() 공개 정적인 메소드

Transforms a string to camel case (e.g. first_name -> firstName).
public static camelize ( string $str ) : string
$str string String in underscore format.
리턴 string

create() 공개 메소드

Creates and saves a model.
public create ( string $name, array $attr = [] ) : object
$name string The model definition name.
$attr array The model attributes.
리턴 object

define() 공개 메소드

Note that this method cannot be used to modify existing definitions. Please use the getDefinition method for that.
public define ( string $name ) : League\FactoryMuffin\Definition
$name string The model definition name.
리턴 League\FactoryMuffin\Definition

deleteSaved() 공개 메소드

Delete all the saved models.
public deleteSaved ( ) : FactoryMuffin
리턴 FactoryMuffin

generate() 보호된 메소드

Generate and set the model attributes.
protected generate ( object $model, array $attr = [] ) : void
$model object The model instance.
$attr array The model attributes.
리턴 void

getDefinition() 공개 메소드

Get a model definition.
public getDefinition ( string $name ) : League\FactoryMuffin\Definition
$name string The model definition name.
리턴 League\FactoryMuffin\Definition

getDefinitions() 공개 메소드

Get all defined model definitions.
public getDefinitions ( ) : League\FactoryMuffin\Definition[]
리턴 League\FactoryMuffin\Definition[]

instance() 공개 메소드

This does not save it in the database. Use create for that.
public instance ( string $name, array $attr = [] ) : object
$name string The model definition name.
$attr array The model attributes.
리턴 object

isPendingOrSaved() 공개 메소드

Is the object saved or will be saved?
public isPendingOrSaved ( object $model ) : boolean
$model object The model instance.
리턴 boolean

loadFactories() 공개 메소드

This method expects either a single path to a directory containing php files, or an array of directory paths, and will "require" each file. These files should be where you define your model definitions.
public loadFactories ( string | string[] $paths ) : FactoryMuffin
$paths string | string[] The directory path(s) to load.
리턴 FactoryMuffin

make() 보호된 메소드

Make an instance of a model.
protected make ( string $name, array $attr, boolean $save ) : object
$name string The model definition name.
$attr array The model attributes.
$save boolean Are we saving, or just creating an instance?
리턴 object

makeClass() 보호된 메소드

Make an instance of a class.
protected makeClass ( string $class, callable $maker = null ) : object
$class string The model class name.
$maker callable The maker callable.
리턴 object

seed() 공개 메소드

Under the hood, we're calling the create method over and over.
public seed ( integer $times, string $name, array $attr = [] ) : object[]
$times integer The number of models to create.
$name string The model definition name.
$attr array The model attributes.
리턴 object[]

triggerCallback() 보호된 메소드

Trigger the callback if we have one.
protected triggerCallback ( object $model, string $name ) : boolean
$model object The model instance.
$name string The model definition name.
리턴 boolean

프로퍼티 상세

$factory 보호되어 있는 프로퍼티

The generator factory instance.
protected GeneratorFactory,League\FactoryMuffin\Generators $factory
리턴 League\FactoryMuffin\Generators\GeneratorFactory

$store 보호되어 있는 프로퍼티

The store instance.
protected StoreInterface,League\FactoryMuffin\Stores $store
리턴 League\FactoryMuffin\Stores\StoreInterface