<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* HomeALarmMONitor Receive an Event
*
* @package HAlMon
* @category Tasks
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Task_Event_Load extends Minion_Task {
protected $_options = array(
'file'=>NULL,
'verbose'=>FALSE,
);
protected function _execute(array $params) {
if (! $params['file'])
throw new Kohana_Exception('--file not supplied');
$dir = dirname($params['file']);
$file = basename($params['file']);
$eo = new Event($params['file']);
if (! $eo->save()) {
if (! Kohana::$config->load('debug')->test_mode)
rename($params['file'],$dir.'/bad-'.$file);
echo 'Bad Event File: '.$params['file'];
die(1);
}
if (! Kohana::$config->load('debug')->test_mode) {
if (Kohana::$config->load('config')->event_file_keep)
rename($params['file'],$dir.'/processed-'.$file);
else
unlink($params['file']);
$eo->trigger();
printf("Processed event(s) %s\n",$eo);
?>