summaryrefslogtreecommitdiffstats
path: root/library/Director/Job/HousekeepingJob.php
blob: 9f3f596efdba4d54453ec4291d09851a66c1bed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

namespace Icinga\Module\Director\Job;

use Icinga\Module\Director\Db\Housekeeping;
use Icinga\Module\Director\Hook\JobHook;
use Icinga\Module\Director\Web\Form\QuickForm;

class HousekeepingJob extends JobHook
{
    protected $housekeeping;

    public function run()
    {
        $this->housekeeping()->runAllTasks();
    }

    public static function getDescription(QuickForm $form)
    {
        return $form->translate(
            'The Housekeeping job provides various task that keep your Director'
            . ' database fast and clean'
        );
    }

    public function isPending()
    {
        return $this->housekeeping()->hasPendingTasks();
    }

    protected function housekeeping()
    {
        if ($this->housekeeping === null) {
            $this->housekeeping = new Housekeeping($this->db());
        }

        return $this->housekeeping;
    }
}