![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Soon/Core/Setup/ |
<?php // phpcs:disable Generic.Files.LineLength.TooLong /** * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @author Hervé Guétin <[email protected]> <@herveguetin> * @copyright Copyright (c) 2016 Agence Soon (http://www.agence-soon.fr) */ declare(strict_types=1); namespace Soon\Core\Setup; use Magento\Email\Model\Template; use Magento\Email\Model\TemplateFactory; use Magento\Framework\App\TemplateTypesInterface; use Magento\Framework\Module\Setup; use Magento\Framework\Module\SetupFactory; use Magento\Framework\Stdlib\DateTime\DateTime; use Magento\Framework\Stdlib\DateTime\DateTimeFactory; class EmailTemplate { /** * Emails to install * * @var array */ private $emails = [ 0 => [ "template_code" => "Nouveau compte (custom)", "template_subject" => '{{trans "Welcome to %store_name" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 1 => [ "template_code" => "Abonnement newsletter (custom)", "template_subject" => "Confirmation d'abonnement à la newsletter", "template_text" => "A compléter", ], 2 => [ "template_code" => "Désabonnement newsletter (custom)", "template_subject" => "Désabonnement à la newsletter", "template_text" => "A compléter", ], 3 => [ "template_code" => "Mot de passe oublié (custom)", "template_subject" => "Confirmation de réinitialisation de mot de passe", "template_text" => "A compléter", ], 4 => [ "template_code" => "Nouvelle commande (custom)", "template_subject" => '{{trans "Your %store_name order confirmation" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 5 => [ "template_code" => "Paiement échoué (custom)", "template_subject" => "Le paiement à échoué", "template_text" => "A compléter", ], 6 => [ "template_code" => "Mise à jour commande (custom)", "template_subject" => '{{trans "Update to your %store_name order" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 7 => [ "template_code" => "Nouvelle expedition (custom)", "template_subject" => '{{trans "Your %store_name order has shipped" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 8 => [ "template_code" => "Mise à jour expédition (custom)", "template_subject" => '{{trans "Update to your %store_name shipment" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 9 => [ "template_code" => "Nouvel avoir (custom)", "template_subject" => '{{trans "Credit memo for your %store_name order" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 10 => [ "template_code" => "Mise à jour avoir (custom)", "template_subject" => '{{trans "Update to your %store_name credit memo" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 11 => [ "template_code" => "Commande annulée (custom)", "template_subject" => "{{var store.getFrontendName()}}: Votre commande n° {{var order.increment_id}} a été annulée", "template_subject" => '{{trans "Your order has been cancelled}}', "template_text" => "A compléter", ], 12 => [ "template_code" => "Expédition partielle (custom)", "template_subject" => '{{trans "Your %store_name order has shipped" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 13 => [ "template_code" => "Nouvelle facture (custom)", "template_subject" => '{{trans "Invoice for your %store_name order\" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], 14 => [ "template_code" => "Mise à jour facture (custom)", "template_subject" => '{{trans "Update to your %store_name invoice" store_name=$store.getFrontendName()}}', "template_text" => "A compléter", ], ]; /** * @var Setup */ private $setup; /** * @var TemplateFactory */ private $templateFactory; /** * @var DateTime */ private $dateTime; /** * EmailTemplate constructor. * @param SetupFactory $setupFactory * @param TemplateFactory $templateFactory * @param DateTimeFactory $dateTimeFactory */ public function __construct( SetupFactory $setupFactory, TemplateFactory $templateFactory, DateTimeFactory $dateTimeFactory ) { $this->setup = $setupFactory->create(); $this->templateFactory = $templateFactory; $this->dateTime = $dateTimeFactory->create(); } /** * Install email templates */ public function install(): void { // Empty existing templates $this->setup->getConnection()->truncateTable($this->setup->getTable('email_template')); // Populate templates array_map(function ($email) { /** @var Template $template */ $template = $this->templateFactory->create(); $data = [ 'template_id' => null, 'template_subject' => $email['template_subject'], 'template_code' => $email['template_code'], 'template_text' => $email['template_text'], 'modified_at' => $this->dateTime->gmtDate(), 'added_at' => $this->dateTime->gmtDate(), 'template_type' => TemplateTypesInterface::TYPE_HTML ]; $template->setData($data); $template->getResource()->save($template); }, $this->emails); } }