Log.php

Go to the documentation of this file.
00001 <?php
00002 
00031 class Robo47_Mail_Transport_Log extends Zend_Mail_Transport_Abstract
00032 {
00033 
00041     public function __construct($formatter, Zend_Log $log,
00042         $logPriority = Zend_Log::INFO,
00043         $logCategory = 'mail')
00044     {
00045         $this->setFormatter($formatter);
00046         $this->setLog($log);
00047         $this->setLogPriority($logPriority);
00048         $this->setLogCategory($logCategory);
00049     }
00050 
00057     public function setLog(Zend_Log $log = null)
00058     {
00059         $this->_log = $log;
00060         return $this;
00061     }
00062 
00068     public function getLog()
00069     {
00070         return $this->_log;
00071     }
00072 
00079     public function setLogCategory($logCategory)
00080     {
00081         $this->_logCategory = $logCategory;
00082         return $this;
00083     }
00084 
00090     public function getLogCategory()
00091     {
00092         return $this->_logCategory;
00093     }
00094 
00101     public function setLogPriority($logPriority)
00102     {
00103         $this->_logPriority = (int) $logPriority;
00104         return $this;
00105     }
00106 
00112     public function getLogPriority()
00113     {
00114         return $this->_logPriority;
00115     }
00116 
00123     public function setFormatter($formatter)
00124     {
00125         if (is_string($formatter)) {
00126             $formatter = new $formatter;
00127         }
00128         if (!$formatter instanceof Robo47_Mail_Transport_Log_Formatter_Interface) {
00129             $message = 'formatter is not instance of ' .
00130                 'Robo47_Mail_Transport_Log_Formatter_Interface';
00131             throw new Robo47_Mail_Transport_Exception($message);
00132         }
00133         $this->_formatter = $formatter;
00134         return $this;
00135     }
00136 
00142     public function getFormatter()
00143     {
00144         return $this->_formatter;
00145     }
00146 
00152     public function send(Zend_Mail $mail)
00153     {
00154         $message = $this->getFormatter()->format($mail);
00155         $category = array('category' => $this->getLogCategory());
00156         $priority = $this->getLogPriority();
00157         $this->getLog()->log($message, $priority, $category);
00158     }
00159 
00164     protected function _sendMail()
00165     {
00166         
00167     }
00168 }