added action to reload twig invoice template (#3876)
This commit is contained in:
@@ -21,17 +21,34 @@ final class InvoiceDocumentSubscriber extends AbstractActionsSubscriber
|
||||
|
||||
public function onActions(PageActionsEvent $event): void
|
||||
{
|
||||
/** @var array<string, InvoiceDocument|null|bool> $payload */
|
||||
$payload = $event->getPayload();
|
||||
if (!\is_array($payload)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var InvoiceDocument|null $document */
|
||||
$document = $payload['document'];
|
||||
$document = \array_key_exists('document', $payload) ? $payload['document'] : null;
|
||||
|
||||
if ($document === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->isGranted('manage_invoice_template')) {
|
||||
$event->addDelete($this->path('invoice_document_delete', ['id' => $document->getId(), 'token' => $payload['token']]), false);
|
||||
if (!$this->isGranted('manage_invoice_template')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var bool $inUse */
|
||||
$inUse = \array_key_exists('in_use', $payload) ? $payload['in_use'] : false;
|
||||
/** @var string $token */
|
||||
$token = \array_key_exists('token', $payload) ? $payload['token'] : null;
|
||||
|
||||
if (!$inUse) {
|
||||
$event->addDelete($this->path('invoice_document_delete', ['id' => $document->getId(), 'token' => $token]), false);
|
||||
}
|
||||
|
||||
if ($document->isTwig()) {
|
||||
$event->addAction('Reload', ['url' => $this->path('admin_invoice_document_reload', ['document' => $document->getId()])]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user