Closed Anyqax closed 8 years ago
This is still possible. The idea now is just that you extend the ModelStore
class, and then pass that through to the FactoryMuffin
constructor.
<?php
use League\FactoryMuffin\FactoryMuffin;
use League\FactoryMuffin\Stores\ModelStore;
class CustomStore extends ModelStore
{
// custom code in here
}
$fm = new FactoryMuffin(new CustomStore);
If you want to force delention to be assumed to have worked, you could just have this:
<?php
use League\FactoryMuffin\FactoryMuffin;
use League\FactoryMuffin\Stores\ModelStore;
class CustomStore extends ModelStore
{
/**
* Delete our object from the db.
*
* @param object $model The model instance.
*
* @throws \League\FactoryMuffin\Exceptions\DeleteMethodNotFoundException
*
* @return mixed
*/
protected function delete($model)
{
parent::delete($model);
return true;
}
}
$fm = new FactoryMuffin(new CustomStore);
ah ok, makes sense, thanks
We are using FactoryMuffin with Propel v1. Propel delete Methods do not return anything, therefore even on successful deletion FactoryMuffin throws a DeletionFailedException. Apparently there was support for custom delete methods in an earlier version: https://github.com/thephpleague/factory-muffin/commit/937c225625b223557f6db23c0d928493d7dd4a19 But that change hasn't survived the facade refactoring in v3: https://github.com/thephpleague/factory-muffin/pull/334/commits/de2a3d2129cad7241451db0dd826adc0ecf74b0d
Are there plans to support custom delete methods again?