Use twig global AttachmentManager in templates.

This commit is contained in:
Jan Böhmer 2020-04-03 14:56:48 +02:00
parent 6b99784238
commit 2dd807bbe6
4 changed files with 7 additions and 16 deletions

View file

@ -81,7 +81,6 @@ abstract class BaseAdminController extends AbstractController
protected $passwordEncoder;
protected $translator;
protected $attachmentHelper;
protected $attachmentSubmitHandler;
protected $commentHelper;
@ -90,7 +89,7 @@ abstract class BaseAdminController extends AbstractController
protected $dataTableFactory;
public function __construct(TranslatorInterface $translator, UserPasswordEncoderInterface $passwordEncoder,
AttachmentManager $attachmentHelper, AttachmentSubmitHandler $attachmentSubmitHandler,
AttachmentSubmitHandler $attachmentSubmitHandler,
EventCommentHelper $commentHelper, HistoryHelper $historyHelper, TimeTravel $timeTravel,
DataTableFactory $dataTableFactory)
{
@ -108,7 +107,6 @@ abstract class BaseAdminController extends AbstractController
$this->translator = $translator;
$this->passwordEncoder = $passwordEncoder;
$this->attachmentHelper = $attachmentHelper;
$this->attachmentSubmitHandler = $attachmentSubmitHandler;
$this->commentHelper = $commentHelper;
$this->historyHelper = $historyHelper;
@ -206,7 +204,6 @@ abstract class BaseAdminController extends AbstractController
return $this->render($this->twig_template, [
'entity' => $entity,
'form' => $form->createView(),
'attachment_helper' => $this->attachmentHelper,
'route_base' => $this->route_base,
'datatable' => $table,
'timeTravel' => $timeTravel_timestamp,
@ -322,7 +319,6 @@ abstract class BaseAdminController extends AbstractController
'form' => $form->createView(),
'import_form' => $import_form->createView(),
'mass_creation_form' => $mass_creation_form->createView(),
'attachment_helper' => $this->attachmentHelper,
'route_base' => $this->route_base,
]);
}

View file

@ -76,15 +76,13 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
class PartController extends AbstractController
{
protected $attachmentManager;
protected $pricedetailHelper;
protected $partPreviewGenerator;
protected $commentHelper;
public function __construct(AttachmentManager $attachmentManager, PricedetailHelper $pricedetailHelper,
public function __construct(PricedetailHelper $pricedetailHelper,
PartPreviewGenerator $partPreviewGenerator, EventCommentHelper $commentHelper)
{
$this->attachmentManager = $attachmentManager;
$this->pricedetailHelper = $pricedetailHelper;
$this->partPreviewGenerator = $partPreviewGenerator;
$this->commentHelper = $commentHelper;
@ -136,7 +134,6 @@ class PartController extends AbstractController
[
'part' => $part,
'datatable' => $table,
'attachment_helper' => $this->attachmentManager,
'pricedetail_helper' => $this->pricedetailHelper,
'pictures' => $this->partPreviewGenerator->getPreviewAttachments($part),
'timeTravel' => $timeTravel_timestamp,
@ -194,7 +191,6 @@ class PartController extends AbstractController
[
'part' => $part,
'form' => $form->createView(),
'attachment_helper' => $this->attachmentManager,
]);
}
@ -231,7 +227,7 @@ class PartController extends AbstractController
* @return Response
*/
public function new(Request $request, EntityManagerInterface $em, TranslatorInterface $translator,
AttachmentManager $attachmentHelper, AttachmentSubmitHandler $attachmentSubmitHandler, ?Part $part = null): Response
AttachmentSubmitHandler $attachmentSubmitHandler, ?Part $part = null): Response
{
if (null === $part) {
$new_part = new Part();
@ -318,7 +314,6 @@ class PartController extends AbstractController
[
'part' => $new_part,
'form' => $form->createView(),
'attachment_helper' => $attachmentHelper,
]);
}
}

View file

@ -22,7 +22,7 @@
{# @var attach \App\Entity\Attachments\Attachment #}
{% if attachment_helper.fileExisting(attach) %}
{% if attachment_manager.fileExisting(attach) %}
{% if not attach.external %}
<br><br>
<h6>
@ -31,7 +31,7 @@
</span>
<br>
<span class="badge badge-secondary">
<i class="fas fa-hdd fa-fw"></i> {{ attachment_helper.humanFileSize(attach) }}
<i class="fas fa-hdd fa-fw"></i> {{ attachment_manager.humanFileSize(attach) }}
</span>
</h6>
{% else %}

View file

@ -19,7 +19,7 @@
{% set attach = attachment.vars.value %}
{% if attachment_helper.fileExisting(attach) %}
{% if attachment_manager.fileExisting(attach) %}
{% if not attach.external %}
<br><br>
<h6>
@ -28,7 +28,7 @@
</span>
<br>
<span class="badge badge-secondary">
<i class="fas fa-hdd fa-fw"></i> {{ attachment_helper.humanFileSize(attach) }}
<i class="fas fa-hdd fa-fw"></i> {{ attachment_manager.humanFileSize(attach) }}
</span>
</h6>
{% else %}