Check if an attachment is valid before showing it in part table.

This commit is contained in:
Jan Böhmer 2019-11-10 20:21:13 +01:00
parent 338b2bb7fe
commit 3812cc88ff

View file

@ -24,6 +24,7 @@ namespace App\DataTables\Column;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Services\Attachments\AttachmentManager;
use App\Services\Attachments\AttachmentURLGenerator; use App\Services\Attachments\AttachmentURLGenerator;
use App\Services\EntityURLGenerator; use App\Services\EntityURLGenerator;
use App\Services\FAIconGenerator; use App\Services\FAIconGenerator;
@ -37,11 +38,13 @@ class PartAttachmentsColumn extends AbstractColumn
protected $FAIconGenerator; protected $FAIconGenerator;
protected $urlGenerator; protected $urlGenerator;
protected $attachmentManager;
public function __construct(FAIconGenerator $FAIconGenerator, EntityURLGenerator $urlGenerator) public function __construct(FAIconGenerator $FAIconGenerator, EntityURLGenerator $urlGenerator, AttachmentManager $attachmentManager)
{ {
$this->FAIconGenerator = $FAIconGenerator; $this->FAIconGenerator = $FAIconGenerator;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$this->attachmentManager = $attachmentManager;
} }
/** /**
@ -62,7 +65,7 @@ class PartAttachmentsColumn extends AbstractColumn
} }
$tmp = ""; $tmp = "";
$attachments = $context->getAttachments()->filter(function (Attachment $attachment) { $attachments = $context->getAttachments()->filter(function (Attachment $attachment) {
return $attachment->getShowInTable(); return $attachment->getShowInTable() && $this->attachmentManager->isFileExisting($attachment);
}); });
$count = 5; $count = 5;