summaryrefslogtreecommitdiffstats
path: root/library/Director/Web/Table/IcingaAppliedServiceTable.php
blob: b669296d84a261e18097f7efb5443e37c4545e0c (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
<?php

namespace Icinga\Module\Director\Web\Table;

use Icinga\Module\Director\Objects\IcingaService;
use gipfl\IcingaWeb2\Link;
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;

class IcingaAppliedServiceTable extends ZfQueryBasedTable
{
    protected $service;

    protected $searchColumns = array(
        'service',
    );

    public function setService(IcingaService $service)
    {
        $this->service = $service;
        return $this;
    }

    public function renderRow($row)
    {
        return $this::row([
            new Link($row->service, 'director/service', ['id' => $row->id])
        ]);
    }

    public function getColumnsToBeRendered()
    {
        return [$this->translate('Servicename')];
    }

    public function prepareQuery()
    {
        return $this->db()->select()->from(
            array('s' => 'icinga_service'),
            array()
        )->joinLeft(
            array('si' => 'icinga_service_inheritance'),
            's.id = si.service_id',
            array()
        )->where(
            'si.parent_service_id = ?',
            $this->service->id
        )->where('s.object_type = ?', 'apply');
    }
}