Sort by alphabet.

This commit is contained in:
James Cole
2016-01-20 15:23:36 +01:00
parent c84f4e2bc0
commit c9e4a09da6
11 changed files with 713 additions and 720 deletions

View File

@@ -25,17 +25,14 @@ use Log;
*/
class Processor
{
/** @var Rule */
protected $rule;
/** @var TransactionJournal */
protected $journal;
/** @var array */
private $triggerTypes = [];
/** @var Rule */
protected $rule;
/** @var array */
private $actionTypes = [];
/** @var array */
private $triggerTypes = [];
/**
* Processor constructor.
@@ -51,6 +48,38 @@ class Processor
$this->actionTypes = Domain::getRuleActions();
}
/**
* @return TransactionJournal
*/
public function getJournal()
{
return $this->journal;
}
/**
* @param TransactionJournal $journal
*/
public function setJournal($journal)
{
$this->journal = $journal;
}
/**
* @return Rule
*/
public function getRule()
{
return $this->rule;
}
/**
* @param Rule $rule
*/
public function setRule($rule)
{
$this->rule = $rule;
}
public function handle()
{
// get all triggers:
@@ -62,6 +91,34 @@ class Processor
}
/**
* @return bool
*/
protected function actions()
{
/**
* @var int $index
* @var RuleAction $action
*/
foreach ($this->rule->ruleActions()->orderBy('order', 'ASC')->get() as $action) {
$type = $action->action_type;
$class = $this->actionTypes[$type];
Log::debug('Action #' . $action->id . ' for rule #' . $action->rule_id . ' (' . $type . ')');
if (!class_exists($class)) {
abort(500, 'Could not instantiate class for rule action type "' . $type . '" (' . $class . ').');
}
/** @var ActionInterface $actionClass */
$actionClass = new $class($action, $this->journal);
$actionClass->act();
if ($action->stop_processing) {
break;
}
}
return true;
}
/**
* TODO stop when stop_processing is present.
*
@@ -101,65 +158,5 @@ class Processor
}
/**
* @return bool
*/
protected function actions()
{
/**
* @var int $index
* @var RuleAction $action
*/
foreach ($this->rule->ruleActions()->orderBy('order', 'ASC')->get() as $action) {
$type = $action->action_type;
$class = $this->actionTypes[$type];
Log::debug('Action #' . $action->id . ' for rule #' . $action->rule_id . ' (' . $type . ')');
if (!class_exists($class)) {
abort(500, 'Could not instantiate class for rule action type "' . $type . '" (' . $class . ').');
}
/** @var ActionInterface $actionClass */
$actionClass = new $class($action, $this->journal);
$actionClass->act();
if ($action->stop_processing) {
break;
}
}
return true;
}
/**
* @return Rule
*/
public function getRule()
{
return $this->rule;
}
/**
* @param Rule $rule
*/
public function setRule($rule)
{
$this->rule = $rule;
}
/**
* @return TransactionJournal
*/
public function getJournal()
{
return $this->journal;
}
/**
* @param TransactionJournal $journal
*/
public function setJournal($journal)
{
$this->journal = $journal;
}
}