Skip to content

Commit

Permalink
cleanup after review
Browse files Browse the repository at this point in the history
  • Loading branch information
maelanleborgne committed Oct 3, 2024
1 parent ec46e92 commit 8d579fe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/Builder/AsyncBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ trait AsyncBuilderTrait
* @var array<string, mixed>
*/
private array $webhookExtraHeaders = [];
/**
* @var \Closure(): string
*/
private \Closure $operationIdGenerator;
private WebhookConfigurationRegistryInterface $webhookConfigurationRegistry;

Expand All @@ -32,7 +35,8 @@ public function generateAsync(): string
'Gotenberg-Webhook-Extra-Http-Headers' => json_encode($this->webhookExtraHeaders, \JSON_THROW_ON_ERROR),
];
if (null !== $this->fileName) {
$headers['Gotenberg-Output-Filename'] = basename($this->fileName, '.pdf');
// Gotenberg will add the extension to the file name (e.g. filename : "file.pdf" => generated file : "file.pdf.pdf").
$headers['Gotenberg-Output-Filename'] = $this->fileName;
}
$this->client->call($this->getEndpoint(), $this->getMultipartFormData(), $headers);

Expand Down Expand Up @@ -71,6 +75,9 @@ public function webhookExtraHeaders(array $extraHeaders): static
return $this;
}

/**
* @param \Closure(): string $operationIdGenerator
*/
public function operationIdGenerator(\Closure $operationIdGenerator): static
{
$this->operationIdGenerator = $operationIdGenerator;
Expand Down
1 change: 0 additions & 1 deletion src/Builder/Pdf/AbstractChromiumPdfBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ protected function addConfiguration(string $configurationName, mixed $value): vo
'fail_on_console_exceptions' => $this->failOnConsoleExceptions($value),
'skip_network_idle_event' => $this->skipNetworkIdleEvent($value),
'metadata' => $this->metadata($value),
'webhook' => null,
default => throw new InvalidBuilderConfiguration(sprintf('Invalid option "%s": no method does not exist in class "%s" to configured it.', $configurationName, static::class)),
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/SensiolabsGotenbergExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public function load(array $configs, ContainerBuilder $container): void
*/
private function cleanUserOptions(array $userConfigurations): array
{
return array_filter($userConfigurations, static function ($config): bool {
return null !== $config;
});
return array_filter($userConfigurations, static function ($config, $configName): bool {
return null !== $config && 'webhook' !== $configName;
}, \ARRAY_FILTER_USE_BOTH);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function testGotenbergConfiguredWithValidConfig(): void
'skip_network_idle_event' => true,
'pdf_format' => 'PDF/A-1b',
'pdf_universal_access' => true,
'webhook' => ['config_name' => 'bar'],
],
'url' => [
'paper_width' => 21,
Expand Down

0 comments on commit 8d579fe

Please sign in to comment.