-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(invoicing): send email w/ attachment included; closes #31
- Loading branch information
Showing
7 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?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\DependencyInjection\Attribute\Autowire; | ||
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, | ||
#[Autowire('%sylius_invoicing.pdf_generator.enabled%')] | ||
private $hasEnabledPdfFileGenerator, | ||
) { | ||
} | ||
|
||
/** | ||
* @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 getAttachments(FormInterface $form): array | ||
{ | ||
$invoice = $form->get('invoice')->getData(); | ||
if (!$invoice instanceof Invoice) { | ||
return []; | ||
} | ||
|
||
if (!$this->hasEnabledPdfFileGenerator) { | ||
return []; | ||
} | ||
|
||
return [$this->invoiceFileProvider->provide($invoice)->fullPath()]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters