Skip to content

Commit

Permalink
Update readme for new constructor argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-gerarts authored Aug 23, 2018
1 parent d2d3412 commit 5558e23
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,14 @@ $config->createMapping(Parent::class, ParentDto::class)
#### Handling object construction
You can specify how the new destination object will be constructed (this isn't
relevant if you use `mapToObject`). You can do this by registering a *factory
callback*. This callback will be passed the source object.
callback*. This callback will be passed both the source object and an instance
of the AutoMapper.

```php
<?php

$config->registerMapping(Source::class, Destination::class)
->beConstructedUsing(function (Source $source): Destination {
->beConstructedUsing(function (Source $source, AutoMapperInterface $mapper): Destination {
return new Destination($source->getProperty());
});
```
Expand Down

0 comments on commit 5558e23

Please sign in to comment.