1<?php
2/*
3** Zabbix
4** Copyright (C) 2001-2021 Zabbix SIA
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19**/
20
21
22/**
23 * Class that holds processed (created and updated) host and template IDs during the current import.
24 */
25class CImportedObjectContainer {
26	/**
27	 * @var array with created and updated hosts.
28	 */
29	protected $hostIds = [];
30
31	/**
32	 * @var array with created and updated templates.
33	 */
34	protected $templateIds = [];
35
36	/**
37	 * Add host IDs that have been created and updated.
38	 *
39	 * @param array $hostIds
40	 */
41	public function addHostIds(array $hostIds) {
42		foreach ($hostIds as $hostId) {
43			$this->hostIds[$hostId] = $hostId;
44		}
45	}
46
47	/**
48	 * Add template IDs that have been created and updated.
49	 *
50	 * @param array $templateIds
51	 */
52	public function addTemplateIds(array $templateIds) {
53		foreach ($templateIds as $templateId) {
54			$this->templateIds[$templateId] = $templateId;
55		}
56	}
57
58	/**
59	 * Checks if host has been created and updated during the current import.
60	 *
61	 * @param string $hostId
62	 *
63	 * @return bool
64	 */
65	public function isHostProcessed($hostId) {
66		return isset($this->hostIds[$hostId]);
67	}
68
69	/**
70	 * Checks if template has been created and updated during the current import.
71	 *
72	 * @param string $templateId
73	 *
74	 * @return bool
75	 */
76	public function isTemplateProcessed($templateId) {
77		return isset($this->templateIds[$templateId]);
78	}
79
80	/**
81	 * Get array of created and updated hosts IDs.
82	 *
83	 * @return array
84	 */
85	public function getHostIds() {
86		return array_values($this->hostIds);
87	}
88
89	/**
90	 * Get array of created and updated template IDs.
91	 *
92	 * @return array
93	 */
94	public function getTemplateIds() {
95		return array_values($this->templateIds);
96	}
97}
98