Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow context for map() with CustomMapper #83

Closed
pysarenkoa opened this issue Jul 29, 2022 · 5 comments
Closed

Allow context for map() with CustomMapper #83

pysarenkoa opened this issue Jul 29, 2022 · 5 comments

Comments

@pysarenkoa
Copy link

Allow context as third argument CustomMapper->mapToObject($source, $destination, array $context = []).
As result it works for mapToObject(), but not for map().
Propose:
line https://github.com/mark-gerarts/automapper-plus/blob/master/src/AutoMapper.php#L92

return $this->getCustomMapper($mapping)->map($source, $destinationClass);

replace to

return $this->getCustomMapper($mapping)->map($source, $destinationClass, $context);
@pysarenkoa pysarenkoa changed the title Allow context for CustomMapper Allow context for map() with CustomMapper Jul 29, 2022
@mark-gerarts
Copy link
Owner

Hi @pysarenkoa, this seems like a very reasonable thing to add. Do you want to open up a PR for this? Otherwise I'll look into adding this myself, let me know.

@pysarenkoa
Copy link
Author

Hi @mark-gerarts, thanks for your quick response. It will great if you do this yourself.

@mark-gerarts
Copy link
Owner

This has been added in release 1.4.0. Keep in mind that the minimum PHP version has been bumped to 7.4 for this release, since 7.3 and below are EOL.

@ahmed-bhs
Copy link

@mark-gerarts does ther any chance to add the feature to 1.3 ? Since my app are using 7.3 php version.

@mark-gerarts
Copy link
Owner

Hi @ahmed-bhs, I'm not really a fan of maintaining several branches. Is it an option that you depend on a specific commit of the library? If so I suggest you depend on ffdb7827e43035fd956dfac368c096276bf870d9, the commit that introduced this feature - but still before the 7.4 requirement. Something like this in composer:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mark-gerarts/automapper-plus.git"
        }
    ],
    "require": {
        "mark-gerarts/automapper-plus": "dev-master#ffdb7827e43035fd956dfac368c096276bf870d9"
    }
}

Then, once you're ready to upgrade to 7.4+, you can swap back to the regular branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants