summaryrefslogtreecommitdiffstats
path: root/modules/setup/application/forms/RequirementsPage.php
blob: d1fb70efc25a855737decd6ad2677dacfb9d9455 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */

namespace Icinga\Module\Setup\Forms;

use Icinga\Web\Form;
use Icinga\Module\Setup\SetupWizard;

/**
 * Wizard page to list setup requirements
 */
class RequirementsPage extends Form
{
    /**
     * The wizard
     *
     * @var SetupWizard
     */
    protected $wizard;

    /**
     * Initialize this page
     */
    public function init()
    {
        $this->setName('setup_requirements');
        $this->setViewScript('form/setup-requirements.phtml');
    }

    /**
     * Set the wizard
     *
     * @param   SetupWizard    $wizard
     *
     * @return  $this
     */
    public function setWizard(SetupWizard $wizard)
    {
        $this->wizard = $wizard;
        return $this;
    }

    /**
     * Return the wizard
     *
     * @return  SetupWizard
     */
    public function getWizard()
    {
        return $this->wizard;
    }

    /**
     * Validate the given form data and check whether the wizard's requirements are fulfilled
     *
     * @param   array   $data   The data to validate
     *
     * @return  bool
     */
    public function isValid($data)
    {
        if (false === parent::isValid($data)) {
            return false;
        }

        return $this->wizard->getRequirements()->fulfilled();
    }
}