thephpleague/factory-muffin — pull request #274 by scottrobertson (2014-08-13 16:39:11+00:00)
Title: Callback

Because of the way things are setup in our codebase, when we create a object, we sometime need to do extra stuff to that object before it's usable. One way of doing this would be to just use the closure generator, but in our ORM, it fails because it tries to save the response from that closure to the DB (the column does not exist). For example:

```
Factory::create('User', [
'thisdoesnotexist' => function() {
return 'something';
}
])
```

One way I was thinking we could solve this would be to have a callback on the create/instance methods. For example:

```
Factory::create('User', [], function($object) {
return $object->do_something_else();
});
```

This would also allow us to do the callback after all generators have been generated, and the object has been saved to the DB. This means that if the callback contents is expecting it to exist in the DB, then it will.

Todo:
- [ ] Create code
- [ ] Tests
- [ ] README documentation
- [ ] Website documentation
- [ ] Add to UPGRADE docs