allow to delete invoice documents (#2968)

This commit is contained in:
Kevin Papst
2021-11-24 10:30:49 +01:00
committed by GitHub
parent ff9acab0fc
commit b062164277
12 changed files with 362 additions and 23 deletions

View File

@@ -0,0 +1,37 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\EventSubscriber\Actions;
use App\Entity\InvoiceDocument;
use App\Event\PageActionsEvent;
class InvoiceDocumentSubscriber extends AbstractActionsSubscriber
{
public static function getActionName(): string
{
return 'invoice_document';
}
public function onActions(PageActionsEvent $event): void
{
$payload = $event->getPayload();
/** @var InvoiceDocument|null $document */
$document = $payload['document'];
if ($document === null) {
return;
}
if ($this->isGranted('manage_invoice_template')) {
$event->addDelete($this->path('invoice_document_delete', ['id' => $document->getId(), 'token' => $payload['token']]), false);
}
}
}