-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Synolia\SyliusMailTesterPlugin\Form\Type\Plugin\InvoicingPlugin; | ||
|
||
use Sylius\InvoicingPlugin\Entity\Invoice; | ||
use Sylius\InvoicingPlugin\Provider\InvoiceFileProviderInterface; | ||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\Form\FormInterface; | ||
use Synolia\SyliusMailTesterPlugin\Form\Type\AbstractType; | ||
|
||
final class InvoiceType extends AbstractType | ||
{ | ||
/** @var string */ | ||
protected static $syliusEmailKey = 'invoice_generated'; | ||
|
||
public function __construct( | ||
private InvoiceFileProviderInterface $invoiceFileProvider, | ||
Check failure on line 20 in src/Form/Type/Plugin/InvoicingPlugin/InvoiceType.php
|
||
) { | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
if (!class_exists(Invoice::class)) { | ||
return; | ||
} | ||
|
||
$builder->add('invoice', EntityType::class, [ | ||
'class' => Invoice::class, | ||
'choice_label' => 'number', | ||
]); | ||
} | ||
|
||
public function attachments(FormInterface $form): array | ||
{ | ||
$invoice = $form->get('invoice')->getData(); | ||
if (!$invoice instanceof Invoice) { | ||
Check failure on line 42 in src/Form/Type/Plugin/InvoicingPlugin/InvoiceType.php
|
||
return []; | ||
} | ||
|
||
return [$this->invoiceFileProvider->provide($invoice)->fullPath()]; | ||
Check failure on line 46 in src/Form/Type/Plugin/InvoicingPlugin/InvoiceType.php
|
||
} | ||
} |