Skip to content
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

[RELEASE_8.13.0] Add new fields form Chromium #117

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/pdf/builders_api/HtmlPdfBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).

* `failOnResourceHttpStatusCodes(array $statusCodes)`:
Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
(default None). (overrides any previous configuration).

* `failOnResourceLoadingFailed(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions load at least one resource. (default false).

* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergPdf to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
Expand Down
8 changes: 8 additions & 0 deletions docs/pdf/builders_api/MarkdownPdfBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).

* `failOnResourceHttpStatusCodes(array $statusCodes)`:
Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
(default None). (overrides any previous configuration).

* `failOnResourceLoadingFailed(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions load at least one resource. (default false).

* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergPdf to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
Expand Down
8 changes: 8 additions & 0 deletions docs/pdf/builders_api/UrlPdfBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).

* `failOnResourceHttpStatusCodes(array $statusCodes)`:
Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
(default None). (overrides any previous configuration).

* `failOnResourceLoadingFailed(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions load at least one resource. (default false).

* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergPdf to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
Expand Down
66 changes: 66 additions & 0 deletions docs/pdf/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
[extraHttpHeaders](#extraHttpHeaders)
[addExtraHttpHeaders](#addExtraHttpHeaders)
[failOnHttpStatusCodes](#failOnHttpStatusCodes)
[failOnResourceHttpStatusCodes](#failOnResourceHttpStatusCodes)
[failOnResourceLoadingFailed](#failOnResourceLoadingFailed)
[failOnConsoleExceptions](#failOnConsoleExceptions)
[skipNetworkIdleEvent](#skipNetworkIdleEvent)

Expand Down Expand Up @@ -896,6 +898,70 @@ class YourController
> [!TIP]
> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium).

### failOnResourceHttpStatusCodes

default: `None`

Return a 409 Conflict response if the HTTP status code from at least one resource
is not acceptable.

```php
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
{
return $gotenberg
->html()
->content('content.html.twig', [
'my_var' => 'value'
])
->failOnResourceHttpStatusCodes([401, 403])
->generate()
->stream()
;
}
}
```

> [!TIP]
> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium).

### failOnResourceLoadingFailed

default: `false`

Return a 409 Conflict response if there are exceptions to load at least one resource
in the Chromium.

```php
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
{
return $gotenberg
->html()
->content('content.html.twig', [
'my_var' => 'value'
])
->failOnResourceLoadingFailed()
->generate()
->stream()
;
}
}
```

> [!TIP]
> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#network-errors-chromium).

### failOnConsoleExceptions

default: `false`
Expand Down
8 changes: 8 additions & 0 deletions docs/screenshot/builders_api/HtmlScreenshotBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).

* `failOnResourceHttpStatusCodes(array $statusCodes)`:
Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
(default None). (overrides any previous configuration).

* `failOnResourceLoadingFailed(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions load at least one resource. (default false).

* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
Expand Down
8 changes: 8 additions & 0 deletions docs/screenshot/builders_api/MarkdownScreenshotBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).

* `failOnResourceHttpStatusCodes(array $statusCodes)`:
Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
(default None). (overrides any previous configuration).

* `failOnResourceLoadingFailed(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions load at least one resource. (default false).

* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
Expand Down
8 changes: 8 additions & 0 deletions docs/screenshot/builders_api/UrlScreenshotBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ document. (default None).
Return a 409 Conflict response if the HTTP status code from
the main page is not acceptable. (default [499,599]). (overrides any previous configuration).

* `failOnResourceHttpStatusCodes(array $statusCodes)`:
Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
(default None). (overrides any previous configuration).

* `failOnResourceLoadingFailed(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions load at least one resource. (default false).

* `failOnConsoleExceptions(bool $bool)`:
Forces GotenbergScreenshot to return a 409 Conflict response if there are
exceptions in the Chromium console. (default false).
Expand Down
66 changes: 66 additions & 0 deletions docs/screenshot/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
[extraHttpHeaders](#extraHttpHeaders)
[addExtraHttpHeaders](#addExtraHttpHeaders)
[failOnHttpStatusCodes](#failOnHttpStatusCodes)
[failOnResourceHttpStatusCodes](#failOnResourceHttpStatusCodes)
[failOnResourceLoadingFailed](#failOnResourceLoadingFailed)
[failOnConsoleExceptions](#failOnConsoleExceptions)
[skipNetworkIdleEvent](#skipNetworkIdleEvent)

Expand Down Expand Up @@ -555,6 +557,70 @@ class YourController
> [!TIP]
> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium).

### failOnResourceHttpStatusCodes

default: `None`

Return a 409 Conflict response if the HTTP status code from at least one resource
is not acceptable.

```php
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
{
return $gotenberg
->html()
->content('content.html.twig', [
'my_var' => 'value'
])
->failOnResourceHttpStatusCodes([401, 403])
->generate()
->stream()
;
}
}
```

> [!TIP]
> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium).

### failOnResourceLoadingFailed

default: `false`

Return a 409 Conflict response if there are exceptions to load at least one resource
in the Chromium.

```php
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
{
return $gotenberg
->html()
->content('content.html.twig', [
'my_var' => 'value'
])
->failOnResourceLoadingFailed()
->generate()
->stream()
;
}
}
```

> [!TIP]
> For more information go to [Gotenberg documentations](https://gotenberg.dev/docs/routes#network-errors-chromium).

### failOnConsoleExceptions

default: `false`
Expand Down
33 changes: 33 additions & 0 deletions src/Builder/Pdf/AbstractChromiumPdfBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function __construct(
'failOnHttpStatusCodes' => function (mixed $value): array {
return $this->encodeData('failOnHttpStatusCodes', $value);
},
'failOnResourceHttpStatusCodes' => function (mixed $value): array {
return $this->encodeData('failOnResourceHttpStatusCodes', $value);
},
'cookies' => fn (mixed $value): array => $this->cookieNormalizer($value, $this->encodeData(...)),
];

Expand Down Expand Up @@ -446,6 +449,34 @@ public function failOnHttpStatusCodes(array $statusCodes): static
return $this;
}

/**
* Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
* (default None). (overrides any previous configuration).
*
* @see https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium
*
* @param list<int<100, 599>> $statusCodes
*/
public function failOnResourceHttpStatusCodes(array $statusCodes): static
{
$this->formFields['failOnResourceHttpStatusCodes'] = $statusCodes;

return $this;
}

/**
* Forces GotenbergScreenshot to return a 409 Conflict response if there are
* exceptions load at least one resource. (default false).
*
* @see https://gotenberg.dev/docs/routes#network-errors-chromium
*/
public function failOnResourceLoadingFailed(bool $bool = true): static
{
$this->formFields['failOnResourceLoadingFailed'] = $bool;

return $this;
}

/**
* Forces GotenbergPdf to return a 409 Conflict response if there are
* exceptions in the Chromium console. (default false).
Expand Down Expand Up @@ -585,6 +616,8 @@ protected function addConfiguration(string $configurationName, mixed $value): vo
'user_agent' => $this->userAgent($value),
'extra_http_headers' => $this->extraHttpHeaders($value),
'fail_on_http_status_codes' => $this->failOnHttpStatusCodes($value),
'fail_on_resource_http_status_codes' => $this->failOnResourceHttpStatusCodes($value),
'fail_on_resource_loading_failed' => $this->failOnResourceLoadingFailed($value),
'fail_on_console_exceptions' => $this->failOnConsoleExceptions($value),
'skip_network_idle_event' => $this->skipNetworkIdleEvent($value),
'metadata' => $this->metadata($value),
Expand Down
33 changes: 33 additions & 0 deletions src/Builder/Screenshot/AbstractChromiumScreenshotBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function __construct(
'failOnHttpStatusCodes' => function (mixed $value): array {
return $this->encodeData('failOnHttpStatusCodes', $value);
},
'failOnResourceHttpStatusCodes' => function (mixed $value): array {
return $this->encodeData('failOnResourceHttpStatusCodes', $value);
},
'cookies' => fn (mixed $value): array => $this->cookieNormalizer($value, $this->encodeData(...)),
];

Expand Down Expand Up @@ -281,6 +284,34 @@ public function failOnHttpStatusCodes(array $statusCodes): static
return $this;
}

/**
* Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable.
* (default None). (overrides any previous configuration).
*
* @see https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium
*
* @param list<int<100, 599>> $statusCodes
*/
public function failOnResourceHttpStatusCodes(array $statusCodes): static
{
$this->formFields['failOnResourceHttpStatusCodes'] = $statusCodes;

return $this;
}

/**
* Forces GotenbergScreenshot to return a 409 Conflict response if there are
* exceptions load at least one resource. (default false).
*
* @see https://gotenberg.dev/docs/routes#network-errors-chromium
*/
public function failOnResourceLoadingFailed(bool $bool = true): static
{
$this->formFields['failOnResourceLoadingFailed'] = $bool;

return $this;
}

/**
* Forces GotenbergScreenshot to return a 409 Conflict response if there are
* exceptions in the Chromium console. (default false).
Expand Down Expand Up @@ -381,6 +412,8 @@ private function addConfiguration(string $configurationName, mixed $value): void
'user_agent' => $this->userAgent($value),
'extra_http_headers' => $this->extraHttpHeaders($value),
'fail_on_http_status_codes' => $this->failOnHttpStatusCodes($value),
'fail_on_resource_http_status_codes' => $this->failOnResourceHttpStatusCodes($value),
'fail_on_resource_loading_failed' => $this->failOnResourceLoadingFailed($value),
'fail_on_console_exceptions' => $this->failOnConsoleExceptions($value),
'skip_network_idle_event' => $this->skipNetworkIdleEvent($value),
'download_from' => $this->downloadFrom($value),
Expand Down
20 changes: 20 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ private function addChromiumPdfOptionsNode(ArrayNodeDefinition $parent): void
->integerPrototype()
->end()
->end()
->arrayNode('fail_on_resource_http_status_codes')
->info('Return a 409 Conflict response if the HTTP status code from at least one resource is not acceptable. - default None. https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium')
->defaultValue([])
Jean-Beru marked this conversation as resolved.
Show resolved Hide resolved
->integerPrototype()
->end()
->end()
->booleanNode('fail_on_resource_loading_failed')
->info('Return a 409 Conflict response if Chromium fails to load at least one resource - default false. https://gotenberg.dev/docs/routes#network-errors-chromium')
->defaultNull()
Jean-Beru marked this conversation as resolved.
Show resolved Hide resolved
->end()
->booleanNode('fail_on_console_exceptions')
->info('Return a 409 Conflict response if there are exceptions in the Chromium console - default false. https://gotenberg.dev/docs/routes#console-exceptions')
->defaultNull()
Expand Down Expand Up @@ -436,6 +446,16 @@ private function addChromiumScreenshotOptionsNode(ArrayNodeDefinition $parent):
->integerPrototype()
->end()
->end()
->arrayNode('fail_on_resource_http_status_codes')
->info('Return a 409 Conflict response if the HTTP status code from the main page is not acceptable. - default None. https://gotenberg.dev/docs/routes#invalid-http-status-codes-chromium')
->defaultValue([])
Jean-Beru marked this conversation as resolved.
Show resolved Hide resolved
->integerPrototype()
->end()
->end()
->booleanNode('fail_on_resource_loading_failed')
->info('Return a 409 Conflict response if Chromium fails to load at least one resource - default false. https://gotenberg.dev/docs/routes#network-errors-chromium')
->defaultNull()
Jean-Beru marked this conversation as resolved.
Show resolved Hide resolved
->end()
->booleanNode('fail_on_console_exceptions')
->info('Return a 409 Conflict response if there are exceptions in the Chromium console - default false. https://gotenberg.dev/docs/routes#console-exceptions')
->defaultNull()
Expand Down
Loading