DemoBundle icon indicating copy to clipboard operation
DemoBundle copied to clipboard

Extending export controler / adding calculated values to pdf.twig export template

Open apiening opened this issue 5 years ago • 3 comments

I have created a copy of an already existing PDF template and saved it unter var/export/myexport.pdf.twig. I modified it to my needs and this worked pretty well.

Now I want to add custom rounding to the duration field where some math is implied. Since I was not able to achieve this just with twig filters, I would like to add an extra field like duration_rounded and do the calculation of this value in PHP.

What would be the best / update safe way to implement this? Is it possible to register to a hook or extend the controller?

apiening avatar Sep 09 '20 13:09 apiening

I think using your own plugin with a simple Twig filter should be sufficient.

kevinpapst avatar Sep 12 '20 14:09 kevinpapst

Thank you. I was able to do the rounding in my template with a few set var = <calculation> steps in between.

I'm still wondering, if I would like to add a custom twig filter, would this be possible to be done update proof like it is possible with Invoice templates placed under /var/export/ so that they don't get overwritten?

apiening avatar Sep 13 '20 12:09 apiening

Plugins will never be overwritten during updates. A plugin is more complex to setup though, but thats what this repository is made for.

kevinpapst avatar Sep 13 '20 12:09 kevinpapst