mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
SyncJob: improve job execution
This commit is contained in:
parent
8ebf04da1e
commit
fe8c4bc6a3
@ -13,20 +13,24 @@ class SyncJob extends JobHook
|
|||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
if ($this->getSetting('apply_changes') === 'y') {
|
$db = $this->db();
|
||||||
$this->syncRule()->applyChanges();
|
$id = $this->getSetting('rule_id');
|
||||||
|
if ($id === '__ALL__') {
|
||||||
|
foreach (SyncRule::loadAll($db) as $rule) {
|
||||||
|
$this->runForRule($rule);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->syncRule()->checkForChanges();
|
$this->runForRule(SyncRule::load($id, $db));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function syncRule()
|
protected function runForRule(SyncRule $rule)
|
||||||
{
|
{
|
||||||
if ($this->rule === null) {
|
if ($this->getSetting('apply_changes') === 'y') {
|
||||||
$this->rule = SyncRule::load($this->getSetting('rule_id'), $this->db());
|
$rule->applyChanges();
|
||||||
|
} else {
|
||||||
|
$rule->checkForChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->rule;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDescription(QuickForm $form)
|
public static function getDescription(QuickForm $form)
|
||||||
@ -88,8 +92,4 @@ class SyncJob extends JobHook
|
|||||||
'__ALL__' => $form->translate('Run all rules at once')
|
'__ALL__' => $form->translate('Run all rules at once')
|
||||||
) + $res;
|
) + $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPending()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user