Skip to content

Commit fcd3cce

Browse files
jonatanrdsantosJonatan Santos
authored andcommitted
Created Module and added a system configuration
0 parents  commit fcd3cce

File tree

22 files changed

+1390
-0
lines changed

22 files changed

+1390
-0
lines changed

Api/Data/ProviderInterface.php

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* ProviderInterface
4+
* php version 8.1.*
5+
*
6+
* @category Jonatanrdsantos
7+
* @package Jonatanrdsantos_Email
8+
* @author Jonatan Santos <jonatan.zarowny+github@gmail.com>
9+
* @copyright 2023 Jonatanrdsantos
10+
* @license https://opensource.org/license/mit/ MIT License
11+
*/
12+
declare(strict_types=1);
13+
14+
namespace Jonatanrdsantos\Email\Api\Data;
15+
16+
interface ProviderInterface
17+
{
18+
/**
19+
* Get id
20+
*
21+
* @return string
22+
*/
23+
public function getId(): string;
24+
25+
/**
26+
* Set id
27+
*
28+
* @param string $id provider identifier
29+
*
30+
* @return $this
31+
*/
32+
public function setId(string $id): self;
33+
34+
/**
35+
* Get label
36+
*
37+
* @return string
38+
*/
39+
public function getLabel(): string;
40+
41+
/**
42+
* Set label
43+
*
44+
* @param string $label provider label
45+
*
46+
* @return $this
47+
*/
48+
public function setLabel(string $label): self;
49+
50+
/**
51+
* Get host
52+
*
53+
* @return string
54+
*/
55+
public function getHost(): string;
56+
57+
/**
58+
* Set host
59+
*
60+
* @param string $host provider host
61+
*
62+
* @return $this
63+
*/
64+
public function setHost(string $host): self;
65+
66+
/**
67+
* Get port
68+
*
69+
* @return int
70+
*/
71+
public function getPort(): int;
72+
73+
/**
74+
* Set port
75+
*
76+
* @param int $port provider port
77+
*
78+
* @return $this
79+
*/
80+
public function setPort(int $port): self;
81+
82+
/**
83+
* Get protocol
84+
*
85+
* @return string
86+
*/
87+
public function getProtocol(): string;
88+
89+
/**
90+
* Set protocol
91+
*
92+
* @param string $protocol provider protocol
93+
*
94+
* @return $this
95+
*/
96+
public function setProtocol(string $protocol): self;
97+
}

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Jonatanrdsantos
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Authentication
4+
* php version 8.1.*
5+
*
6+
* @category Jonatanrdsantos
7+
* @package Jonatanrdsantos_Email
8+
* @author Jonatan Santos <jonatan.zarowny+github@gmail.com>
9+
* @copyright 2023 Jonatanrdsantos
10+
* @license https://opensource.org/license/mit/ MIT License
11+
*/
12+
declare(strict_types=1);
13+
14+
namespace Jonatanrdsantos\Email\Model\Config\Source;
15+
16+
use Magento\Framework\Data\OptionSourceInterface;
17+
18+
class Authentication implements OptionSourceInterface
19+
{
20+
/**
21+
* SMTP option value
22+
*/
23+
private const SMTP = 'smtp';
24+
25+
/**
26+
* Plain option value
27+
*/
28+
private const PLAIN = 'plain';
29+
30+
/**
31+
* Login option value
32+
*/
33+
private const LOGIN = 'login';
34+
35+
/**
36+
* Return array of options as value-label pairs
37+
*
38+
* @return array{
39+
* array{value: 'smtp', label: \Magento\Framework\Phrase},
40+
* array{value: 'plain', label: \Magento\Framework\Phrase},
41+
* array{value: 'login', label: \Magento\Framework\Phrase}
42+
* }
43+
*/
44+
public function toOptionArray(): array
45+
{
46+
return [
47+
['value' => self::SMTP, 'label' => __('SMTP')],
48+
['value' => self::PLAIN, 'label' => __('Plain')],
49+
['value' => self::LOGIN, 'label' => __('Login')]
50+
];
51+
}
52+
}

Model/Config/Source/Protocol.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Protocol
4+
* php version 8.1.*
5+
*
6+
* @category Jonatanrdsantos
7+
* @package Jonatanrdsantos_Email
8+
* @author Jonatan Santos <jonatan.zarowny+github@gmail.com>
9+
* @copyright 2023 Jonatanrdsantos
10+
* @license https://opensource.org/license/mit/ MIT License
11+
*/
12+
declare(strict_types=1);
13+
14+
namespace Jonatanrdsantos\Email\Model\Config\Source;
15+
16+
use Magento\Framework\Data\OptionSourceInterface;
17+
18+
class Protocol implements OptionSourceInterface
19+
{
20+
/**
21+
* None option value
22+
*/
23+
private const NONE = '';
24+
25+
/**
26+
* SSL option value
27+
*/
28+
private const SSL = 'ssl';
29+
30+
/**
31+
* TLS option value
32+
*/
33+
private const TLS = 'tls';
34+
35+
/**
36+
* Return array of options as value-label pairs
37+
*
38+
* @return array{
39+
* array{value: '', label: \Magento\Framework\Phrase},
40+
* array{value: 'ssl', label: \Magento\Framework\Phrase},
41+
* array{value: 'tls', label: \Magento\Framework\Phrase}
42+
* }
43+
*/
44+
public function toOptionArray(): array
45+
{
46+
return [
47+
['value' => self::NONE, 'label' => __('None')],
48+
['value' => self::SSL, 'label' => __('SSL')],
49+
['value' => self::TLS, 'label' => __('TLS')]
50+
];
51+
}
52+
}

Model/Config/Source/Provider.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Provider
4+
* php version 8.1.*
5+
*
6+
* @category Jonatanrdsantos
7+
* @package Jonatanrdsantos_Email
8+
* @author Jonatan Santos <jonatan.zarowny+github@gmail.com>
9+
* @copyright 2023 Jonatanrdsantos
10+
* @license https://opensource.org/license/mit/ MIT License
11+
*/
12+
declare(strict_types=1);
13+
14+
namespace Jonatanrdsantos\Email\Model\Config\Source;
15+
16+
use Magento\Framework\Data\OptionSourceInterface;
17+
use Jonatanrdsantos\Email\Model\Provider\CollectionFactory;
18+
19+
class Provider implements OptionSourceInterface
20+
{
21+
/**
22+
* Custom option value
23+
*/
24+
private const CUSTOM = '';
25+
26+
/**
27+
* Initializes Provider
28+
*
29+
* @param CollectionFactory $collectionFactory Provider Collection Factory
30+
*/
31+
public function __construct(
32+
private readonly CollectionFactory $collectionFactory
33+
) {
34+
}
35+
36+
/**
37+
* Return array of options as value-label pairs
38+
*
39+
* @return array<mixed>
40+
*/
41+
public function toOptionArray(): array
42+
{
43+
$collection = $this->collectionFactory->create();
44+
return array_merge(
45+
[['value' => self::CUSTOM, 'label' => __('Custom')]],
46+
$collection->toOptionArray()
47+
);
48+
}
49+
}

0 commit comments

Comments
 (0)