-
-
Notifications
You must be signed in to change notification settings - Fork 981
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
Fix setOptions method #974
Conversation
@barryvdh test added |
I think this is better indeed, but not sure if this is a breaking change. Although setOptions might not have been usable. |
@barryvdh, Depending on the implementation of the config this could have breaking changes. As I've discovered is the case in some of our projects config after updating the dependency to v2.1.0 |
How where you using this? |
We are using this mainly by calling Right now ( Thus the functionality of the |
I'd suggest to make a second optional parameter on the function which will determine if the configs should be merged or not. To maintain backward compatibility I'd suggest something like this. public function setOptions(array $options, bool $mergeWithDefaults = false): self
{
if ($mergeWithDefaults ) {
$dompdfOptions = new Options(app()->make('dompdf.options'));
$dompdfOptions->set($options);
} else {
$dompdfOptions = new Options($options);
}
$this->dompdf->setOptions($dompdfOptions);
return $this;
} Ah, after posting this reply I see you just reverted the change. |
@barryvdh Now everything fails for me because it resets to options that are not valid, instead of the default options that I defined in my configuration file, it is a breaking change for me
This seems like a better option. |
+1 |
I think it is not necessary to deprecate the
setOptions
method, the problem was that it removed all the default settings, but withapp()->make('dompdf.options')
we get a copy ofconfig/dompdf.php
before adding the options, the functionality is maintained and it is shorter to use than the original methodhttps://github.com/dompdf/dompdf/blob/56a660ce045ee27c84154c60b612c936ddb86398/src/Dompdf.php#L1327
Also with an empty array we could reset options to default
config/dompdf.php
config, example:$pdf->setOptions([])
Closes #793 (comment)
UPDATE: Test added