summaryrefslogtreecommitdiffstats
path: root/library/Director/Test/ImportSourceDummy.php
blob: 4ac1d09884772ce5d9f061fa77b65c869acf02a3 (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
<?php

namespace Icinga\Module\Director\Test;

use Icinga\Module\Director\Hook\ImportSourceHook;

class ImportSourceDummy extends ImportSourceHook
{
    protected static $rows = array();

    /**
     * Returns an array containing importable objects
     *
     * @return array
     */
    public function fetchData()
    {
        return self::$rows;
    }

    /**
     * Returns a list of all available columns
     *
     * @return array
     */
    public function listColumns()
    {
        $keys = array();
        foreach (self::$rows as $row) {
            $keys = array_merge($keys, array_keys($row));
        }
        return $keys;
    }

    public static function clearRows()
    {
        self::$rows = array();
    }

    public static function setRows($rows)
    {
        static::clearRows();
        foreach ($rows as $row) {
            static::addRow($row);
        }
    }

    public static function addRow($row)
    {
        self::$rows[] = (object) $row;
    }
}