summaryrefslogtreecommitdiffstats
path: root/modules/setup/library/Setup/Requirement/SetRequirement.php
blob: 77cbaf01818d5370b760b50912a31d4bbf215a38 (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
<?php
/* Icinga Web 2 | (c) 2020 Icinga GmbH | GPLv2+ */

namespace Icinga\Module\Setup\Requirement;

use Icinga\Module\Setup\Requirement;

/**
 * Add requirement field
 *
 * @package Icinga\Module\Setup\Requirement
 */
class SetRequirement extends Requirement
{
    protected function evaluate()
    {
        $condition = $this->getCondition();

        if ($condition->getState()) {
            $this->setStateText(sprintf(
                mt('setup', '%s is available.'),
                $this->getAlias() ?: $this->getTitle()
            ));
            return true;
        }

        $this->setStateText(sprintf(
            mt('setup', '%s is missing.'),
            $this->getAlias() ?: $this->getTitle()
        ));

        return false;
    }
}