Add middleware feature (extensions)#46
Conversation
|
I'm sorry for the big pull request, but it was in the TODO list and I really need this feature :). Hope the implementation is what you are expecting for a middleware feature. |
b5acca5 to
445da4c
Compare
|
It does not look like a middleware for me. I think |
|
Hi @Toilal, this is a big PR indeed! So as a head's up: it will take a while before I find the time to review this. At a first glance I'll have to agree with @BoShurik. The usage of the before/after/skip/override constants seem like something that won't be needed in a middleware stack based on callables. Still, lots of work went into this, and with a few changes I'll definitely merge this in master. I'll focus on the other PR's first though, before I start on this one. |
|
I see what you mean about middleware. I could refactor to provide to the middleware function a callable parameter that would perform the default mapping operation when called, so that middleware implementation can invoke it at the start of the method, at the end of the method, or not at all. This would then make the "before/after/override/skip" thing useless. |
|
I'm closing this pull request in favor or #47 |
You can register middlewares to customize how automapper works internally and define
global behaviors.
The following example will set 42 to any
idproperty that would have beennull.Middleware feature open up many extension capabilities, feel free to check PHPDocs
from PropertyMiddleware and
MapperMiddleware interfaces for details.