Commit 8333a14e by Qiang Xue

Added parameters to fileTransportCallback.

parent 9867ffb6
...@@ -81,6 +81,12 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont ...@@ -81,6 +81,12 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
* @var callback a PHP callback that will be called by [[send()]] when [[useFileTransport]] is true. * @var callback a PHP callback that will be called by [[send()]] when [[useFileTransport]] is true.
* The callback should return a file name which will be used to save the email message. * The callback should return a file name which will be used to save the email message.
* If not set, the file name will be generated based on the current timestamp. * If not set, the file name will be generated based on the current timestamp.
*
* The signature of the callback is:
*
* ~~~
* function ($mailer, $message)
* ~~~
*/ */
public $fileTransportCallback; public $fileTransportCallback;
...@@ -272,7 +278,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont ...@@ -272,7 +278,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
mkdir($path, 0777, true); mkdir($path, 0777, true);
} }
if ($this->fileTransportCallback !== null) { if ($this->fileTransportCallback !== null) {
$file = $path . '/' . call_user_func($this->fileTransportCallback); $file = $path . '/' . call_user_func($this->fileTransportCallback, $this, $message);
} else { } else {
$time = microtime(true); $time = microtime(true);
$file = $path . '/' . date('Ymd-His-', $time) . sprintf('%04d', (int)(($time - (int)$time) * 10000)) . '-' . sprintf('%04d', mt_rand(0, 10000)) . '.txt'; $file = $path . '/' . date('Ymd-His-', $time) . sprintf('%04d', (int)(($time - (int)$time) * 10000)) . '-' . sprintf('%04d', mt_rand(0, 10000)) . '.txt';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment