本文整理汇总了PHP中CArrayHelper::getByKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP CArrayHelper::getByKeys方法的具体用法?PHP CArrayHelper::getByKeys怎么用?PHP CArrayHelper::getByKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArrayHelper
的用法示例。
在下文中一共展示了CArrayHelper::getByKeys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHosts
public function getHosts()
{
$hostsData = array();
if (!empty($this->data['hosts'])) {
foreach ($this->data['hosts'] as $host) {
$host = $this->renameData($host, array('proxyid' => 'proxy_hostid'));
CArrayHelper::convertFieldToArray($host, 'interfaces');
if (!empty($host['interfaces'])) {
foreach ($host['interfaces'] as $inum => $interface) {
$host['interfaces'][$inum] = $this->renameData($interface, array('default' => 'main'));
}
}
CArrayHelper::convertFieldToArray($host, 'templates');
if (empty($host['templates'])) {
unset($host['templates']);
}
CArrayHelper::convertFieldToArray($host, 'macros');
CArrayHelper::convertFieldToArray($host, 'groups');
if (!empty($host['inventory']) && isset($host['inventory']['inventory_mode'])) {
$host['inventory_mode'] = $host['inventory']['inventory_mode'];
unset($host['inventory']['inventory_mode']);
} else {
$host['inventory_mode'] = HOST_INVENTORY_DISABLED;
}
$hostsData[] = CArrayHelper::getByKeys($host, array('inventory', 'proxy', 'groups', 'templates', 'macros', 'interfaces', 'host', 'status', 'ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password', 'name', 'inventory_mode'));
}
}
return $hostsData;
}
示例2: getHosts
/**
* Get hosts from the imported data.
*
* @return array
*/
public function getHosts()
{
$hosts = [];
if (array_key_exists('hosts', $this->data)) {
foreach ($this->data['hosts'] as $host) {
$host = CArrayHelper::renameKeys($host, ['proxyid' => 'proxy_hostid']);
if (array_key_exists('interfaces', $host)) {
foreach ($host['interfaces'] as $inum => $interface) {
$host['interfaces'][$inum] = CArrayHelper::renameKeys($interface, ['default' => 'main']);
}
}
if (array_key_exists('inventory', $host)) {
if (array_key_exists('inventory_mode', $host['inventory'])) {
$host['inventory_mode'] = $host['inventory']['inventory_mode'];
unset($host['inventory']['inventory_mode']);
} else {
$host['inventory_mode'] = HOST_INVENTORY_DISABLED;
}
}
$hosts[] = CArrayHelper::getByKeys($host, ['inventory', 'proxy', 'groups', 'templates', 'macros', 'interfaces', 'host', 'status', 'description', 'ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password', 'name', 'inventory_mode', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk']);
}
}
return $hosts;
}