profection the Mail module ,add console route match rule in AuthenticationService

This commit is contained in:
Jianxuan Li 2014-12-24 15:59:42 +08:00
parent 80c90895c9
commit 91044298c8
3 changed files with 28 additions and 4 deletions

View File

@ -42,6 +42,11 @@ class AuthenticationService
$controller = $e->getRouteMatch()->getParam('controller');
$action = $e->getRouteMatch()->getParam('action');
if($module == 'Engine' && $namespace == 'ConsoleApp')
{
return true;
}
// view::Dump($e->getRouteMatch()->getMatchedRouteName() . ":" . $controller."-".$action,false);
$this->preCookieCheck();

View File

@ -31,6 +31,7 @@ class Mail extends AbstractEventManager implements ServiceManagerAwareInterface{
public $body;
public $type;
public $transport;
public $from;
public function setServiceManager(ServiceManager $serviceManager)
{
@ -101,7 +102,7 @@ class Mail extends AbstractEventManager implements ServiceManagerAwareInterface{
}
//设置默认发件人
public function setDefaultForm()
public function setDefaultFrom()
{
$this->mail->setFrom($this->config['smtp']['username'],$this->config['smtp']['name']);
}
@ -125,6 +126,14 @@ class Mail extends AbstractEventManager implements ServiceManagerAwareInterface{
}//加载模板
/**
* @param $from
*/
public function setFrom($from)
{
$this->from = $from;
}
//使用loadTemplate 的结果发送邮件
//在此之前需要使用 $this->mail->addTo()添加收件人
public function send($from = NULL){
@ -148,10 +157,13 @@ class Mail extends AbstractEventManager implements ServiceManagerAwareInterface{
$this->mail->setBody($this->body);
}
if(empty($from))
if(empty($from) && empty($this->from))
{
$this->setDefaultForm();
$this->setDefaultFrom();
}else{
if(!empty($this->from))
$this->mail->setFrom($this->from['email'],$this->from['name']);
if(!empty($from))
$this->mail->setFrom($from['email'],$from['name']);
}

View File

@ -106,6 +106,13 @@ class Template implements ServiceManagerAwareInterface
$template_data = $this->fetch($key);
if(empty($data) || !is_array($data) || count($data) < 1)
return [
'subject' => $template_data['subject'],
'body' => $template_data['body'],
'type' => isset($template_data['type']) ? $template_data['type'] : self::DEFAULT_TEMPLATE_TYPE
];
$patterns = array();
$replacements = array();