Skip to content

Commit

Permalink
FRW-229: Remove Swiftmailer dependency (#9624)
Browse files Browse the repository at this point in the history
FRW-229 Remove Swiftmailer dependency
  • Loading branch information
olhalivitchuk authored Nov 11, 2022
1 parent db46379 commit 81d8d1b
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
"spryker/gui": "^3.0.0",
"spryker/kernel": "^3.33.0",
"spryker/mail": "^4.6.0",
"spryker/mail-extension": "^1.0.0",
"spryker/oms-extension": "^1.3.0",
"spryker/propel": "^3.28.0",
"spryker/propel-orm": "^1.16.0",
"spryker/sales": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^10.0.0 || ^11.0.0",
"spryker/sales-extension": "^1.7.0",
"spryker/store": "^1.5.0",
"spryker/symfony": "^3.0.0",
"spryker/transfer": "^3.18.0",
"spryker/transfer": "^3.25.0",
"spryker/util-network": "^1.1.0",
"spryker/util-sanitize": "^2.0.0",
"spryker/util-text": "^1.1.0"
Expand Down
2 changes: 1 addition & 1 deletion dependency.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"include": {
"spryker/transfer": "Provides transfer objects definition with associative and decimal functionality."
"spryker/transfer": "Provides transfer objects definition with `::get*OrFail()` functionality."
}
}
14 changes: 14 additions & 0 deletions src/Spryker/Shared/Oms/Transfer/oms.transfer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
<property name="order" type="Order"/>
<property name="shipmentGroups" type="ShipmentGroup[]" singular="shipmentGroup"/>
<property name="type" type="string"/>
<property name="subject" type="string"/>
<property name="subjectTranslationParameters" type="string[]" associative="true" singular="subjectTranslationParameter"/>
<property name="locale" type="Locale"/>
<property name="templates" type="MailTemplate[]" singular="template"/>
<property name="recipients" type="MailRecipient[]" singular="recipient"/>
</transfer>

<transfer name="Order">
Expand Down Expand Up @@ -189,4 +193,14 @@
<property name="timeoutTimestamp" type="int"/>
</transfer>

<transfer name="MailRecipient">
<property name="email" type="string"/>
<property name="name" type="string"/>
</transfer>

<transfer name="MailTemplate">
<property name="name" type="string"/>
<property name="isHtml" type="bool"/>
</transfer>

</transfers>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace Spryker\Zed\Oms\Communication\Plugin\Mail;

use Generated\Shared\Transfer\MailRecipientTransfer;
use Generated\Shared\Transfer\MailTemplateTransfer;
use Generated\Shared\Transfer\MailTransfer;
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
use Spryker\Zed\MailExtension\Dependency\Plugin\MailTypeBuilderPluginInterface;

/**
* @method \Spryker\Zed\Oms\OmsConfig getConfig()
* @method \Spryker\Zed\Oms\Communication\OmsCommunicationFactory getFactory()
* @method \Spryker\Zed\Oms\Business\OmsFacadeInterface getFacade()
* @method \Spryker\Zed\Oms\Persistence\OmsQueryContainerInterface getQueryContainer()
*/
class OrderConfirmationMailTypeBuilderPlugin extends AbstractPlugin implements MailTypeBuilderPluginInterface
{
/**
* @var string
*/
protected const MAIL_TYPE = 'order confirmation mail';

/**
* @var string
*/
protected const MAIL_TEMPLATE_HTML = 'oms/mail/order_confirmation.html.twig';

/**
* @var string
*/
protected const MAIL_TEMPLATE_TEXT = 'oms/mail/order_confirmation.text.twig';

/**
* @var string
*/
protected const GLOSSARY_KEY_MAIL_SUBJECT = 'mail.order.confirmation.subject';

/**
* {@inheritDoc}
* - Returns the name of mail for an order confirmation mail.
*
* @api
*
* @return string
*/
public function getName(): string
{
return static::MAIL_TYPE;
}

/**
* {@inheritDoc}
* - Builds the `MailTransfer` with data for an order confirmation mail.
*
* @api
*
* @param \Generated\Shared\Transfer\MailTransfer $mailTransfer
*
* @return \Generated\Shared\Transfer\MailTransfer
*/
public function build(MailTransfer $mailTransfer): MailTransfer
{
/** @var \Generated\Shared\Transfer\OrderTransfer $orderTransfer */
$orderTransfer = $mailTransfer->getOrderOrFail();

return $mailTransfer
->setSubject(static::GLOSSARY_KEY_MAIL_SUBJECT)
->addTemplate(
(new MailTemplateTransfer())
->setName(static::MAIL_TEMPLATE_HTML)
->setIsHtml(true),
)
->addTemplate(
(new MailTemplateTransfer())
->setName(static::MAIL_TEMPLATE_TEXT)
->setIsHtml(false),
)
->addRecipient(
(new MailRecipientTransfer())
->setEmail($orderTransfer->getEmailOrFail())
->setName(sprintf('%s %s', $orderTransfer->getFirstName(), $orderTransfer->getLastName())),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Spryker\Zed\Mail\Dependency\Plugin\MailTypePluginInterface;

/**
* @deprecated Use {@link \Spryker\Zed\Oms\Communication\Plugin\Mail\OrderConfirmationMailTypeBuilderPlugin} instead.
*
* @method \Spryker\Zed\Oms\Business\OmsFacadeInterface getFacade()
* @method \Spryker\Zed\Oms\Communication\OmsCommunicationFactory getFactory()
* @method \Spryker\Zed\Oms\OmsConfig getConfig()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace Spryker\Zed\Oms\Communication\Plugin\Mail;

use Generated\Shared\Transfer\MailRecipientTransfer;
use Generated\Shared\Transfer\MailTemplateTransfer;
use Generated\Shared\Transfer\MailTransfer;
use Spryker\Zed\Kernel\Communication\AbstractPlugin;
use Spryker\Zed\MailExtension\Dependency\Plugin\MailTypeBuilderPluginInterface;

/**
* @method \Spryker\Zed\Oms\OmsConfig getConfig()
* @method \Spryker\Zed\Oms\Communication\OmsCommunicationFactory getFactory()
* @method \Spryker\Zed\Oms\Business\OmsFacadeInterface getFacade()
* @method \Spryker\Zed\Oms\Persistence\OmsQueryContainerInterface getQueryContainer()
*/
class OrderShippedMailTypeBuilderPlugin extends AbstractPlugin implements MailTypeBuilderPluginInterface
{
/**
* @var string
*/
protected const MAIL_TYPE = 'order shipped mail';

/**
* @var string
*/
protected const MAIL_TEMPLATE_HTML = 'oms/mail/order_shipped.html.twig';

/**
* @var string
*/
protected const MAIL_TEMPLATE_TEXT = 'oms/mail/order_shipped.text.twig';

/**
* @var string
*/
protected const GLOSSARY_KEY_MAIL_SUBJECT = 'mail.order.shipped.subject';

/**
* @var string
*/
protected const PARAMETER_ORDER_REFERENCE = '%orderReference%';

/**
* {@inheritDoc}
* - Returns the name of mail for an order shipped mail.
*
* @api
*
* @return string
*/
public function getName(): string
{
return static::MAIL_TYPE;
}

/**
* {@inheritDoc}
* - Builds the `MailTransfer` with data for an order shipped mail.
*
* @api
*
* @param \Generated\Shared\Transfer\MailTransfer $mailTransfer
*
* @return \Generated\Shared\Transfer\MailTransfer
*/
public function build(MailTransfer $mailTransfer): MailTransfer
{
/** @var \Generated\Shared\Transfer\OrderTransfer $orderTransfer */
$orderTransfer = $mailTransfer->getOrderOrFail();

return $mailTransfer
->setSubject(static::GLOSSARY_KEY_MAIL_SUBJECT)
->setSubjectTranslationParameters([static::PARAMETER_ORDER_REFERENCE => $orderTransfer->getOrderReferenceOrFail()])
->addTemplate(
(new MailTemplateTransfer())
->setName(static::MAIL_TEMPLATE_HTML)
->setIsHtml(true),
)
->addTemplate(
(new MailTemplateTransfer())
->setName(static::MAIL_TEMPLATE_TEXT)
->setIsHtml(false),
)
->addRecipient(
(new MailRecipientTransfer())
->setEmail($orderTransfer->getEmailOrFail())
->setName(sprintf('%s %s', $orderTransfer->getFirstName(), $orderTransfer->getLastName())),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Spryker\Zed\Mail\Dependency\Plugin\MailTypePluginInterface;

/**
* @deprecated Use {@link \Spryker\Zed\Oms\Communication\Plugin\Mail\OrderShippedMailTypeBuilderPlugin} instead.
*
* @method \Spryker\Zed\Oms\Business\OmsFacadeInterface getFacade()
* @method \Spryker\Zed\Oms\Communication\OmsCommunicationFactory getFactory()
* @method \Spryker\Zed\Oms\OmsConfig getConfig()
Expand Down

0 comments on commit 81d8d1b

Please sign in to comment.