PHP code example of synolia / sylius-mail-tester-plugin

1. Go to this page and download the library: Download synolia/sylius-mail-tester-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

synolia / sylius-mail-tester-plugin example snippets


    Synolia\SyliusMailTesterPlugin\SynoliaSyliusMailTesterPlugin::class => ['all' => true],
    



declare(strict_types=1);

namespace Synolia\SyliusMailTesterPlugin\Form\Type;

use Sylius\Component\Core\Model\Order;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Synolia\SyliusMailTesterPlugin\Resolver\ResolvableFormTypeInterface;

public class CustomEmailType extends AbstractType implements ResolvableFormTypeInterface
{
    /** @var string */
    private const SYLIUS_EMAIL_KEY = 'custom_email'; //this should match your email identification key in sylius_mailer.yaml.

    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        parent::buildForm($builder, $options);

        /**
         * The key 'order' represent the name of the variable in your template.
         * Then you specify the type of the variable.
         * In this example we provide a list of all available orders.
         */
        $builder->add('order', EntityType::class, [
            'class' => Order::class,
            'choice_label' => 'number',
        ]);
    }

    public function support(string $emailKey): bool
    {
        return $emailKey === self::SYLIUS_EMAIL_KEY;
    }

    public function getCode(): string
    {
        return self::SYLIUS_EMAIL_KEY;
    }

    public function getFormType(string $emailKey): ResolvableFormTypeInterface
    {
        return $this;
    }
}