Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from mageplaza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
haitv282 authored Jul 24, 2020
2 parents 1cf31fc + d203015 commit 886c254
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
49 changes: 49 additions & 0 deletions Model/Config/Backend/Email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_EmailAttachments
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\EmailAttachments\Model\Config\Backend;

use Magento\Framework\App\Config\Value;
use Magento\Framework\Exception\ValidatorException;

/**
* Class Email
* @package Mageplaza\EmailAttachments\Model\Config\Backend
*/
class Email extends Value
{
/**
* @return Value|void
* @throws ValidatorException
*/
public function beforeSave()
{
if (!empty($this->getValue())) {
$valueArray = explode(',', $this->getValue());
foreach ($valueArray as $value) {
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
throw new ValidatorException(__('Invalid email format.'));
}
}
}
parent::beforeSave(); // TODO: Change the autogenerated stub
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.5"
},
"type": "magento2-module",
"version": "1.0.4",
"version": "1.0.5",
"license": "proprietary",
"authors": [
{
Expand Down
2 changes: 2 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
</field>
<field id="cc_to" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>CC to Emails</label>
<backend_model>Mageplaza\EmailAttachments\Model\Config\Backend\Email</backend_model>
<comment>Comma-separated</comment>
</field>
<field id="bcc_to" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>BCC to Emails</label>
<backend_model>Mageplaza\EmailAttachments\Model\Config\Backend\Email</backend_model>
<comment>Comma-separated</comment>
</field>
<field id="is_enabled_attach_pdf" translate="label" sortOrder="40" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
Expand Down
1 change: 1 addition & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"Invalid email format.","Invalid email format."
Invoice,Invoice
Shipment,Shipment
"Credit Memo","Credit Memo"
Expand Down

0 comments on commit 886c254

Please sign in to comment.