1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the O2System Framework package. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @author Steeve Andrian Salim |
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
namespace O2System\Framework\Services; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
use O2System\Email\DataStructures\Config; |
17
|
|
|
use O2System\Email\Message; |
18
|
|
|
use O2System\Email\Spool; |
19
|
|
|
use O2System\Spl\Traits\Collectors\ConfigCollectorTrait; |
20
|
|
|
use O2System\Spl\Traits\Collectors\ErrorCollectorTrait; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class Email |
24
|
|
|
* @package O2System\Framework\Services |
25
|
|
|
*/ |
26
|
|
|
class Email extends Message |
27
|
|
|
{ |
28
|
|
|
use ConfigCollectorTrait; |
29
|
|
|
use ErrorCollectorTrait; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Email::__construct |
33
|
|
|
*/ |
34
|
|
|
public function __construct() |
35
|
|
|
{ |
36
|
|
|
if ($config = config()->loadFile('email', true)) { |
|
|
|
|
37
|
|
|
$this->setConfig($config->getArrayCopy()); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
// ------------------------------------------------------------------------ |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Email::subject |
45
|
|
|
* |
46
|
|
|
* @param string $subject |
47
|
|
|
* |
48
|
|
|
* @return Message |
49
|
|
|
*/ |
50
|
|
|
public function subject($subject) |
51
|
|
|
{ |
52
|
|
|
$subject = language()->getLine($subject); |
53
|
|
|
|
54
|
|
|
return parent::subject($subject); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// ------------------------------------------------------------------------ |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Email::with |
61
|
|
|
* |
62
|
|
|
* @param mixed $vars |
63
|
|
|
* @param mixed $value |
64
|
|
|
* |
65
|
|
|
* @return static |
66
|
|
|
*/ |
67
|
|
|
public function with($vars, $value = null) |
68
|
|
|
{ |
69
|
|
|
view()->with($vars, $value); |
70
|
|
|
|
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
// ------------------------------------------------------------------------ |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Email::template |
78
|
|
|
* |
79
|
|
|
* @param string $filename |
80
|
|
|
* @param array $vars |
81
|
|
|
* |
82
|
|
|
* @return static |
83
|
|
|
*/ |
84
|
|
|
public function template($filename, array $vars = []) |
85
|
|
|
{ |
86
|
|
|
if ($view = view()->load($filename, $vars, true)) { |
87
|
|
|
$this->body($view); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
return $this; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
// ------------------------------------------------------------------------ |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Email::send |
97
|
|
|
* |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
|
|
public function send() |
101
|
|
|
{ |
102
|
|
|
$spool = new Spool(new Config($this->config)); |
103
|
|
|
|
104
|
|
|
if ($spool->send($this)) { |
105
|
|
|
return true; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
$this->setErrors($spool->getErrors()); |
109
|
|
|
|
110
|
|
|
return false; |
111
|
|
|
} |
112
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.