Moved attachment form submit logic to a seperate service.

This commit is contained in:
Jan Böhmer 2019-10-19 17:13:13 +02:00
parent 1f7c122ba2
commit d382021fee
9 changed files with 279 additions and 73 deletions

View file

@ -56,12 +56,15 @@ class AttachmentFormType extends AbstractType
protected $attachment_helper;
protected $trans;
protected $urlGenerator;
protected $allow_attachments_download;
public function __construct(AttachmentHelper $attachmentHelper, TranslatorInterface $trans, UrlGeneratorInterface $urlGenerator)
public function __construct(AttachmentHelper $attachmentHelper, TranslatorInterface $trans,
UrlGeneratorInterface $urlGenerator, bool $allow_attachments_downloads)
{
$this->attachment_helper = $attachmentHelper;
$this->trans = $trans;
$this->urlGenerator = $urlGenerator;
$this->allow_attachments_download = $allow_attachments_downloads;
}
public function buildForm(FormBuilderInterface $builder, array $options)
@ -94,6 +97,13 @@ class AttachmentFormType extends AbstractType
]
]);
$builder->add('downloadURL', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('attachment.edit.download_url'),
'mapped' => false,
'disabled' => !$this->allow_attachments_download,
'attr' => ['class' => 'form-control-sm'],
'label_attr' => ['class' => 'checkbox-custom']]);
$builder->add('file', FileType::class, [
'label' => $this->trans->trans('attachment.edit.file'),
'mapped' => false,