本文整理汇总了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;
}