Skip to content

Commit

Permalink
[Improvement]: Add possibility to pass metadata to gotenberg-chromium…
Browse files Browse the repository at this point in the history
… processor (#66)

* Pass metadata to gotenberg-chromium processor

* Add backwards compatibility layer for gotenberg-php v1

* Check the existence of metadata only once

Co-authored-by: Sebastian Blank <sebastian.bl@gmx.de>

* Just use formValue to support both v1 and v2

Co-authored-by: JiaJia Ji <kingjia90@gmail.com>

* Remove empty new line

* Revert "Remove empty new line"

This reverts commit e057251.

* Revert "Just use formValue to support both v1 and v2"

This reverts commit 437b18f.

* Update minimum versions for gotenberg/gotenberg-php dependency

* Ignore phpstan error because code should not be reachable when formValue is protected

* Try checking formValue with is_callable

Co-authored-by: Sebastian Blank <sebastian.bl@gmx.de>

* Pass metadata to gotenberg-chromium on version > 2.2

---------

Co-authored-by: Sebastian Blank <sebastian.bl@gmx.de>
Co-authored-by: JiaJia Ji <kingjia90@gmail.com>
  • Loading branch information
3 people authored Jun 7, 2024
1 parent c59c08c commit 2c3934b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require-dev": {
"phpstan/phpstan": "^1.10.5",
"phpstan/phpstan-symfony": "^1.2.20",
"gotenberg/gotenberg-php": "^1.0 || ^2.0",
"gotenberg/gotenberg-php": "^1.1.8 || ^2.2",
"chrome-php/chrome": "^1.8",
"codeception/codeception": "^5.0.3",
"codeception/module-symfony": "^3.1.0",
Expand Down
5 changes: 5 additions & 0 deletions src/Processor/Gotenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ public function getPdfFromString(string $html, array $params = [], bool $returnF
$chromium->extraHttpHeaders($params['extraHttpHeaders']);
}

// metadata is only passed on gotenberg-php > 2.2
if (isset($params['metadata']) && method_exists($chromium, 'metadata')) {
$chromium->metadata($params['metadata']);
}

$request = $chromium->outputFilename($tempFileName)->html(Stream::string('processor.html', $html));

if ($returnFilePath) {
Expand Down

0 comments on commit 2c3934b

Please sign in to comment.