thephpleague/factory-muffin — pull request #277 by GrahamCampbell (2014-08-13 17:41:47+00:00)
Title: [2.1] Callbacks

### This pull request tracks the development of feature:
* You may discuss this feature here, on this pull request.
* Please send pull requests for this feature to the `feature/callbacks` branch.
* This branch will be merged into the master once everyone is happy with this feature.
* It must have complete tests and documentation before it is merged.

### Initial proposal:

> 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';
> }
> ])
> ```

### Usage example:

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