1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8class Search_GlobalSource_Static implements Search_GlobalSource_Interface
9{
10	private $data;
11	private $typeMap;
12
13	function __construct($data, $typeMap)
14	{
15		$this->data = $data;
16		$this->typeMap = $typeMap;
17	}
18
19	function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = [])
20	{
21		$out = [];
22
23		foreach ($this->data["$objectType:$objectId"] as $key => $value) {
24			$type = $this->typeMap[$key];
25			$out[$key] = $typeFactory->$type($value);
26		}
27
28		return $out;
29	}
30
31	function getProvidedFields()
32	{
33		return array_keys($this->typeMap);
34	}
35
36	function getGlobalFields()
37	{
38		return array_fill_keys(array_keys($this->typeMap), true);
39	}
40}
41