本文整理匯總了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;
}