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
Add decorator infrastructure for plugins #1519
base: master
Are you sure you want to change the base?
Conversation
You may not name the method clone |
How about It might be nice to just use the same Dompdf object twice, but I couldn't get that to work. |
(Btw, tests would be much faster with a |
Did you see my cool
PHP writing HTML writing PHP with a string of PHP with variables. Waaat. It's not pretty, but it makes the input HTML much prettier:
So that's what this PR can do, indirectly. |
It's an interesting concept. We'll take a closer look as we have time. |
Excellent. There are more usages at rudiedirkx/dompdf-demo |
Did ya did ya? I'd very much like to change my patched dompdf to a stable release. I'm sure many users would be happy to have some template sugar like |
I'm slammed these days so I'll only be working on bug fixes for the next release. Will keep you updated on progress with this enhancement. |
I want to make a few decorators for Dompdf tweaks I often use. To make a decorator, I need a simple interface that Dompdf already implements, so my decorators can implement the same interface. With decorators, you make make very useful Dompdf plugins that interact at any (public) moment in the Dompdf flow.
I've made 2 (no stealing!):
<body>
in input HTML to make multiple PDF and then merge them into oneThis PR doesn't actually include the plugins, but it allows for them by creating the infrastructure. All of this is doable without this PR, but not as pretty. I've only included the methods I need, not all public methods, because there are many. Maybe a few more would be more useful for other scenario's, but I haven't missed any. It's fully backward compatible too.
Demo decorators and current hacky infrastructure at rudiedirkx/dompdf-demo
Very simple example to make all input documents UTF-8, because typing is such a hassle:
This simple example could of course be much easier by extending
Dompdf
. The benefit from decorators comes from combining them, and adding config and logic that doesn't belong in Dompdf itself..