Create a new factory muffin instance.
public __construct ( League\FactoryMuffin\Stores\StoreInterface $store = null, |
||
$store | League\FactoryMuffin\Stores\StoreInterface | The store instance. |
$factory | The generator factory instance. | |
return | void |
/** * @param array $models ex: [ Model1::className(), Model2::className() ] * @throws ModelException * @throws ModelNotFoundException * @throws \League\FactoryMuffin\Exceptions\DefinitionAlreadyDefinedException */ public function __construct($models = []) { parent::__construct(new ModelStoreYii()); if (!empty($models)) { $this->loadModelDefinitions($models); } }
/** * @param array $models ex: [ Model1::className(), Model2::className() ] * @throws ModelException * @throws ModelNotFoundException * @throws \League\FactoryMuffin\Exceptions\DefinitionAlreadyDefinedException */ public function __construct($models = []) { parent::__construct(new ModelStoreYii()); // map factory muffin CRUD methods to Yii2's methods $this->setSaveMethod('save')->setDeleteMethod('delete'); if (!empty($models)) { $this->loadModelDefinitions($models); } }