-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom constructor and middleware support to custom mappers
- Loading branch information
Showing
9 changed files
with
87 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace AutoMapperPlus; | ||
|
||
use AutoMapperPlus\Exception\UnregisteredMappingException; | ||
|
||
/** | ||
* Interface ClassMapperInterface | ||
* | ||
* @package AutoMapperPlus | ||
*/ | ||
interface ClassMapperInterface | ||
{ | ||
/** | ||
* Maps an object to an instance of class $to, provided a mapping is | ||
* configured. | ||
* | ||
* @param array|object $source | ||
* The source object. | ||
* @param string $targetClass | ||
* The target classname. | ||
* @param array $context | ||
* An arbitrary array of values that will be passed to supporting | ||
* mapping operations (e.g. MapFrom) to alter their behaviour based on | ||
* the context. | ||
* This is not explicitly required on the interface yet to preserve | ||
* backwards compatibility, but will be added in version 2.0. | ||
* @return mixed | ||
* An instance of class $to. | ||
* @throws UnregisteredMappingException | ||
*/ | ||
public function map($source, string $targetClass/**, array $context = [] */); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace AutoMapperPlus; | ||
|
||
use AutoMapperPlus\Exception\UnregisteredMappingException; | ||
|
||
/** | ||
* Interface ObjectMapperInterface | ||
* | ||
* @package AutoMapperPlus | ||
*/ | ||
interface DestinationMapperInterface | ||
{ | ||
/** | ||
* Maps properties of object $from to an existing object $to. | ||
* | ||
* @param array|object $source | ||
* The source object. | ||
* @param object $destination | ||
* The target object. | ||
* @param array $context | ||
* See MapperInterface::map() | ||
* @return mixed | ||
* $to, with properties copied from $from. | ||
* @throws UnregisteredMappingException | ||
*/ | ||
public function mapToObject($source, $destination/**, array $context = [] */); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters