equal
deleted
inserted
replaced
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Log |
16 * @package Zend_Log |
17 * @subpackage Writer |
17 * @subpackage Writer |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Mail.php 22971 2010-09-18 20:32:24Z mikaelkael $ |
20 * @version $Id: Mail.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
22 |
23 /** Zend_Log_Writer_Abstract */ |
23 /** Zend_Log_Writer_Abstract */ |
24 require_once 'Zend/Log/Writer/Abstract.php'; |
24 require_once 'Zend/Log/Writer/Abstract.php'; |
25 |
25 |
37 * completion, so any log entries accumulated are sent in a single email. |
37 * completion, so any log entries accumulated are sent in a single email. |
38 * |
38 * |
39 * @category Zend |
39 * @category Zend |
40 * @package Zend_Log |
40 * @package Zend_Log |
41 * @subpackage Writer |
41 * @subpackage Writer |
42 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
42 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
43 * @license http://framework.zend.com/license/new-bsd New BSD License |
43 * @license http://framework.zend.com/license/new-bsd New BSD License |
44 * @version $Id: Mail.php 22971 2010-09-18 20:32:24Z mikaelkael $ |
44 * @version $Id: Mail.php 24593 2012-01-05 20:35:02Z matthew $ |
45 */ |
45 */ |
46 class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract |
46 class Zend_Log_Writer_Mail extends Zend_Log_Writer_Abstract |
47 { |
47 { |
48 /** |
48 /** |
49 * Array of formatted events to include in message body. |
49 * Array of formatted events to include in message body. |
104 * MethodMap for Zend_Mail's headers |
104 * MethodMap for Zend_Mail's headers |
105 * |
105 * |
106 * @var array |
106 * @var array |
107 */ |
107 */ |
108 protected static $_methodMapHeaders = array( |
108 protected static $_methodMapHeaders = array( |
109 'from' => 'setFrom', |
109 'from' => 'setFrom', |
110 'to' => 'addTo', |
110 'to' => 'addTo', |
111 'cc' => 'addCc', |
111 'cc' => 'addCc', |
112 'bcc' => 'addBcc', |
112 'bcc' => 'addBcc', |
113 ); |
113 ); |
114 |
114 |
146 |
146 |
147 if (isset($config['layout']) || isset($config['layoutOptions'])) { |
147 if (isset($config['layout']) || isset($config['layoutOptions'])) { |
148 $writer->setLayout($config); |
148 $writer->setLayout($config); |
149 } |
149 } |
150 if (isset($config['layoutFormatter'])) { |
150 if (isset($config['layoutFormatter'])) { |
151 $layoutFormatter = new $config['layoutFormatter']; |
151 $layoutFormatter = new $config['layoutFormatter']; |
152 $writer->setLayoutFormatter($layoutFormatter); |
152 $writer->setLayoutFormatter($layoutFormatter); |
153 } |
153 } |
154 if (isset($config['subjectPrependText'])) { |
154 if (isset($config['subjectPrependText'])) { |
155 $writer->setSubjectPrependText($config['subjectPrependText']); |
155 $writer->setSubjectPrependText($config['subjectPrependText']); |
156 } |
156 } |
183 /** |
183 /** |
184 * Construct a Zend_Mail instance based on a configuration array |
184 * Construct a Zend_Mail instance based on a configuration array |
185 * |
185 * |
186 * @param array $config |
186 * @param array $config |
187 * @return Zend_Mail |
187 * @return Zend_Mail |
|
188 * @throws Zend_Log_Exception |
188 */ |
189 */ |
189 protected static function _constructMailFromConfig(array $config) |
190 protected static function _constructMailFromConfig(array $config) |
190 { |
191 { |
191 $mailClass = 'Zend_Mail'; |
192 $mailClass = 'Zend_Mail'; |
192 if (isset($config['mail'])) { |
193 if (isset($config['mail'])) { |
211 $method = self::$_methodMapHeaders[$header]; |
212 $method = self::$_methodMapHeaders[$header]; |
212 if (is_array($address) && isset($address['name']) |
213 if (is_array($address) && isset($address['name']) |
213 && !is_numeric($address['name']) |
214 && !is_numeric($address['name']) |
214 ) { |
215 ) { |
215 $params = array( |
216 $params = array( |
216 $address['email'], |
217 $address['email'], |
217 $address['name'] |
218 $address['name'] |
218 ); |
219 ); |
219 } else if (is_array($address) && isset($address['email'])) { |
220 } else if (is_array($address) && isset($address['email'])) { |
220 $params = array($address['email']); |
221 $params = array($address['email']); |
221 } else { |
222 } else { |
222 $params = array($address); |
223 $params = array($address); |
231 /** |
232 /** |
232 * Construct a Zend_Layout instance based on a configuration array |
233 * Construct a Zend_Layout instance based on a configuration array |
233 * |
234 * |
234 * @param array $config |
235 * @param array $config |
235 * @return Zend_Layout |
236 * @return Zend_Layout |
|
237 * @throws Zend_Log_Exception |
236 */ |
238 */ |
237 protected function _constructLayoutFromConfig(array $config) |
239 protected function _constructLayoutFromConfig(array $config) |
238 { |
240 { |
239 $config = array_merge(array( |
241 $config = array_merge(array( |
240 'layout' => 'Zend_Layout', |
242 'layout' => 'Zend_Layout', |
329 * once, this method cannot be used if the Zend_Mail object already has a |
331 * once, this method cannot be used if the Zend_Mail object already has a |
330 * subject set. |
332 * subject set. |
331 * |
333 * |
332 * @param string $subject Subject prepend text. |
334 * @param string $subject Subject prepend text. |
333 * @return Zend_Log_Writer_Mail |
335 * @return Zend_Log_Writer_Mail |
|
336 * @throws Zend_Log_Exception |
334 */ |
337 */ |
335 public function setSubjectPrependText($subject) |
338 public function setSubjectPrependText($subject) |
336 { |
339 { |
337 if ($this->_mail->getSubject()) { |
340 if ($this->_mail->getSubject()) { |
338 throw new Zend_Log_Exception( |
341 throw new Zend_Log_Exception( |