本文整理匯總了PHP中CArrayHelper::convertFieldToArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP CArrayHelper::convertFieldToArray方法的具體用法?PHP CArrayHelper::convertFieldToArray怎麽用?PHP CArrayHelper::convertFieldToArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CArrayHelper
的用法示例。
在下文中一共展示了CArrayHelper::convertFieldToArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: formatDiscoveryRule
/**
* Format discovery rule.
*
* @param array $discoveryRule
*
* @return array
*/
protected function formatDiscoveryRule(array $discoveryRule)
{
$discoveryRule = $this->renameItemFields($discoveryRule);
if (!empty($discoveryRule['item_prototypes'])) {
foreach ($discoveryRule['item_prototypes'] as &$prototype) {
$prototype = $this->renameItemFields($prototype);
CArrayHelper::convertFieldToArray($prototype, 'applications');
}
unset($prototype);
} else {
$discoveryRule['item_prototypes'] = array();
}
if (!empty($discoveryRule['trigger_prototypes'])) {
foreach ($discoveryRule['trigger_prototypes'] as &$trigger) {
$trigger = $this->renameTriggerFields($trigger);
}
unset($trigger);
} else {
$discoveryRule['trigger_prototypes'] = array();
}
if (!empty($discoveryRule['graph_prototypes'])) {
foreach ($discoveryRule['graph_prototypes'] as &$graph) {
$graph = $this->renameGraphFields($graph);
}
unset($graph);
} else {
$discoveryRule['graph_prototypes'] = array();
}
if (!empty($discoveryRule['host_prototypes'])) {
foreach ($discoveryRule['host_prototypes'] as &$hostPrototype) {
CArrayHelper::convertFieldToArray($hostPrototype, 'group_prototypes');
CArrayHelper::convertFieldToArray($hostPrototype, 'templates');
}
unset($hostPrototype);
} else {
$discoveryRule['host_prototypes'] = array();
}
return $discoveryRule;
}
示例2: formatDiscoveryRule
/**
* Format discovery rule.
*
* @param array $discoveryRule
*
* @return array
*/
protected function formatDiscoveryRule(array $discoveryRule)
{
$discoveryRule = $this->renameItemFields($discoveryRule);
if (!empty($discoveryRule['item_prototypes'])) {
foreach ($discoveryRule['item_prototypes'] as &$prototype) {
$prototype = $this->renameItemFields($prototype);
CArrayHelper::convertFieldToArray($prototype, 'applications');
}
unset($prototype);
} else {
$discoveryRule['item_prototypes'] = array();
}
if (!empty($discoveryRule['trigger_prototypes'])) {
foreach ($discoveryRule['trigger_prototypes'] as &$trigger) {
$trigger['expression'] = $this->triggerExpressionConverter->convert($trigger['expression']);
$trigger = $this->renameTriggerFields($trigger);
}
unset($trigger);
} else {
$discoveryRule['trigger_prototypes'] = array();
}
if (!empty($discoveryRule['graph_prototypes'])) {
foreach ($discoveryRule['graph_prototypes'] as &$graph) {
$graph = $this->renameGraphFields($graph);
}
unset($graph);
} else {
$discoveryRule['graph_prototypes'] = array();
}
if (!empty($discoveryRule['host_prototypes'])) {
foreach ($discoveryRule['host_prototypes'] as &$hostPrototype) {
CArrayHelper::convertFieldToArray($hostPrototype, 'group_prototypes');
CArrayHelper::convertFieldToArray($hostPrototype, 'templates');
}
unset($hostPrototype);
} else {
$discoveryRule['host_prototypes'] = array();
}
if (!empty($discoveryRule['filter'])) {
// array filter structure
if (is_array($discoveryRule['filter'])) {
CArrayHelper::convertFieldToArray($discoveryRule['filter'], 'conditions');
} else {
list($filterMacro, $filterValue) = explode(':', $discoveryRule['filter']);
if ($filterMacro) {
$discoveryRule['filter'] = array('evaltype' => CONDITION_EVAL_TYPE_AND_OR, 'formula' => '', 'conditions' => array(array('macro' => $filterMacro, 'value' => $filterValue, 'operator' => CONDITION_OPERATOR_REGEXP)));
} else {
unset($discoveryRule['filter']);
}
}
}
return $discoveryRule;
}