This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
halmon/application/classes/Task/Event/Load.php

45 lines
1013 B
PHP
Raw Normal View History

2013-10-17 04:15:13 +00:00
<?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');
$eo = new Event($params['file']);
if (! $eo->save()) {
if (! Kohana::$config->load('debug')->test_mode)
rename($params['file'],$params['file'].'.bad');
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'],$params['file'].'.processed');
else
unlink($params['file']);
}
$eo->trigger();
printf("Processed event(s) %s\n",$eo);
}
}
?>