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

Commit 886c254

Browse files
Merge pull request #21 from mageplaza/develop
Develop
2 parents 1cf31fc + d203015 commit 886c254

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

Model/Config/Backend/Email.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Mageplaza
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Mageplaza.com license that is
8+
* available through the world-wide-web at this URL:
9+
* https://www.mageplaza.com/LICENSE.txt
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this extension to newer
14+
* version in the future.
15+
*
16+
* @category Mageplaza
17+
* @package Mageplaza_EmailAttachments
18+
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
19+
* @license https://www.mageplaza.com/LICENSE.txt
20+
*/
21+
22+
namespace Mageplaza\EmailAttachments\Model\Config\Backend;
23+
24+
use Magento\Framework\App\Config\Value;
25+
use Magento\Framework\Exception\ValidatorException;
26+
27+
/**
28+
* Class Email
29+
* @package Mageplaza\EmailAttachments\Model\Config\Backend
30+
*/
31+
class Email extends Value
32+
{
33+
/**
34+
* @return Value|void
35+
* @throws ValidatorException
36+
*/
37+
public function beforeSave()
38+
{
39+
if (!empty($this->getValue())) {
40+
$valueArray = explode(',', $this->getValue());
41+
foreach ($valueArray as $value) {
42+
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
43+
throw new ValidatorException(__('Invalid email format.'));
44+
}
45+
}
46+
}
47+
parent::beforeSave(); // TODO: Change the autogenerated stub
48+
}
49+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"mageplaza/module-core": "^1.4.5"
66
},
77
"type": "magento2-module",
8-
"version": "1.0.4",
8+
"version": "1.0.5",
99
"license": "proprietary",
1010
"authors": [
1111
{

etc/adminhtml/system.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@
3535
</field>
3636
<field id="cc_to" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
3737
<label>CC to Emails</label>
38+
<backend_model>Mageplaza\EmailAttachments\Model\Config\Backend\Email</backend_model>
3839
<comment>Comma-separated</comment>
3940
</field>
4041
<field id="bcc_to" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
4142
<label>BCC to Emails</label>
43+
<backend_model>Mageplaza\EmailAttachments\Model\Config\Backend\Email</backend_model>
4244
<comment>Comma-separated</comment>
4345
</field>
4446
<field id="is_enabled_attach_pdf" translate="label" sortOrder="40" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">

i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"Invalid email format.","Invalid email format."
12
Invoice,Invoice
23
Shipment,Shipment
34
"Credit Memo","Credit Memo"

0 commit comments

Comments
 (0)