本文整理汇总了PHP中CakeEmail::viewRender方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeEmail::viewRender方法的具体用法?PHP CakeEmail::viewRender怎么用?PHP CakeEmail::viewRender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeEmail
的用法示例。
在下文中一共展示了CakeEmail::viewRender方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send
*
* A bit of a misnomer, because this actually just adds it to a CakeResque
* queue. The actual sending of the email will be performed later by a worker.
*
* @params CakeEmail $email
* @return array
*/
public function send(CakeEmail $email)
{
// Take a copy of the existing configuration.
$config = array('headers' => $email->getHeaders(), 'from' => $email->from(), 'sender' => $email->sender(), 'replyTo' => $email->replyTo(), 'readReceipt' => $email->readReceipt(), 'returnPath' => $email->returnPath(), 'to' => $email->to(), 'cc' => $email->cc(), 'bcc' => $email->bcc(), 'subject' => $email->subject(), 'viewRender' => $email->viewRender(), 'viewVars' => $email->viewVars(), 'emailFormat' => $email->emailFormat(), 'messageId' => $email->messageId(), 'attachments' => $email->attachments());
// unset($config['config']['transport']);
$template = $email->template();
$config['template'] = $template['template'];
$config['layout'] = $template['layout'];
// Clean it up to avoid errors.
$config = array_filter($config, function ($v) {
return (bool) $v;
});
debug($config);
// Include a message, if they sent one via plain text.
$message = $email->message(CakeEmail::MESSAGE_HTML) ? null : $email->message(CakeEmail::MESSAGE_TEXT);
// Drop it in a queue.
Resque::enqueue('email', 'ResqueEmail.EmailShell', array('send', $config, $message));
return array('headers' => $email->getHeaders(), 'message' => $email->message());
}
示例2: sendMail
//.........这里部分代码省略.........
}
// 件名
$cakeEmail->subject($title);
//From
$fromName = $from = '';
if (!empty($options['from'])) {
$from = $options['from'];
} else {
if (!empty($this->siteConfigs['email'])) {
$from = $this->siteConfigs['email'];
if (strpos($from, ',') !== false) {
$from = explode(',', $from);
}
} else {
$from = $toAddress;
}
}
if (!empty($options['fromName'])) {
$fromName = $options['fromName'];
} else {
if (!empty($this->siteConfigs['formal_name'])) {
$fromName = $this->siteConfigs['formal_name'];
} else {
$formalName = Configure::read('BcApp.title');
}
}
$cakeEmail->from($from, $fromName);
//Reply-To
if (!empty($options['replyTo'])) {
$replyTo = $options['replyTo'];
} else {
$replyTo = $from;
}
$cakeEmail->replyTo($replyTo);
//Return-Path
if (!empty($options['returnPath'])) {
$returnPath = $options['returnPath'];
} else {
$returnPath = $from;
}
$cakeEmail->returnPath($returnPath);
//$sender
if (!empty($options['sender'])) {
$cakeEmail->sender($options['sender']);
}
//$theme
if ($this->theme) {
$cakeEmail->theme($this->theme);
}
if (!empty($options['theme'])) {
$cakeEmail->theme($options['theme']);
}
//viewRender (利用するviewクラスを設定する)
$cakeEmail->viewRender('BcApp');
//template
if (!empty($options['template'])) {
$layoutPath = $subDir = $plugin = '';
if ($options['agentTemplate'] && Configure::read('BcRequest.agent')) {
$layoutPath = Configure::read('BcRequest.agentPrefix');
$subDir = Configure::read('BcRequest.agentPrefix');
}
list($plugin, $template) = pluginSplit($options['template']);
if ($subDir) {
$template = "{$subDir}/{$template}";
}
if (!empty($plugin)) {
$template = "{$plugin}.{$template}";
}
if (!empty($options['layout'])) {
$cakeEmail->template($template, $options['layout']);
} else {
$cakeEmail->template($template);
}
$content = '';
if (is_array($body)) {
$cakeEmail->viewVars($body);
} else {
$cakeEmail->viewVars(array('body' => $body));
}
} else {
$content = $body;
}
// $attachments tmp file path
$attachments = array();
if (!empty($options['attachments'])) {
if (!is_array($options['attachments'])) {
$attachments = array($options['attachments']);
} else {
$attachments = $options['attachments'];
}
}
$cakeEmail->attachments($attachments);
try {
$cakeEmail->send($content);
return true;
} catch (Exception $e) {
$this->log($e->getMessage());
return false;
}
}