<?php
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
namespace app\extensions\adapter\logger;
class Growl extends \lithium\core\Object {
protected $growl = null;
/**
* Class constructor.
*
* @param array $config
* @return void
*/
public function __construct(array $config = array()) {
parent::__construct($config);
// fugly:
@require_once 'Net/Growl.php';
if (class_exists('\\Net_Growl')) {
$notifications = array('Errors', 'Messages');
$app = 'Lithium';
$this->growl = new \Net_Growl($app, $notifications);
}
}
/**
* Appends $data to file $type.
*
* @param string $type
* @param string $message
* @return boolean `True` on successful write, `false` otherwise.
*/
public function write($type, $message) {
if (!$this->growl) {
return function() {};
}
$growl = $this->growl;
return function($self, $params, $chain) use ($growl) {
$growl->notify(
'Messages',
'Lithium log',
"{$params['type']}: {$params['message']}"
);
return true;
};
}
}
?>