Source
CDataHelper::addItemData(self::$itemids['top_hosts_trap_text'], 'Text for text item');
<?php
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
class TopHostsWidget {
/**
* Id of items by name.
*
* @var integer
*/
protected static $itemids;
/**
* Create data for testDashboardTopHostsWidget test.
*
* @return array
*/
public static function load() {
// Create items with value type - text, log, character.
CDataHelper::call('item.create', [
[
'name' => 'top_hosts_trap_text',
'key_' => 'top_hosts_trap_text',
'hostid' => 10084,
'type' => 2,
'value_type' => 4
],
[
'name' => 'top_hosts_trap_log',
'key_' => 'top_hosts_trap_log',
'hostid' => 10084,
'type' => 2,
'value_type' => 2
],
[
'name' => 'top_hosts_trap_char',
'key_' => 'top_hosts_trap_char',
'hostid' => 10084,
'type' => 2,
'value_type' => 1
]
]);
self::$itemids = CDataHelper::getIds('name');