Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CakeEmailHandler for the CakePHP framework #162

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/Monolog/Handler/CakeEmailHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/*
* This file is part of the Monolog package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Monolog\Handler;

use Monolog\Logger;
use Monolog\Handler\MailHandler;

/**
* CakeEmailHandler uses CakeEmail to send the emails.
*
* @author Jad Bitar <jadbitar@mac.com>
*/
class CakeEmailHandler extends MailHandler {

protected $_to;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the underscore.

protected $_subject;
protected $_config;

/**
* @param string|array $to The receiver of the mail
* @param string $subject The subject of the mail
* @param string $from The CakeEmail configuration to use
* @param integer $level The minimum logging level at which this handler will be triggered
* @param boolean $bubble Whether the messages that are handled can bubble up the stack or not
*/
public function __construct($to, $subject, $config = 'default', $level = Logger::ERROR, $bubble = true) {
parent::__construct($level, $bubble);
$this->_to = $to;
$this->_subject = $subject;
$this->_config = $config;
}

/**
* {@inheritdoc}
*/
public function send($content, array $records) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the curly brace should be on its own line

\CakeEmail::deliver($this->_to, $this->_subject, $content, $this->_config);
}

}