本文整理汇总了PHP中Icinga\Application\Config::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::toArray方法的具体用法?PHP Config::toArray怎么用?PHP Config::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Application\Config
的用法示例。
在下文中一共展示了Config::toArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: diffPropertyDeletions
/**
* Search for deleted properties and use the editor to delete these entries
*
* @param Config $oldconfig The config representing the state before the change
* @param Config $newconfig The config representing the state after the change
* @param Document $doc
*
* @throws ProgrammingError
*/
protected function diffPropertyDeletions(Config $oldconfig, Config $newconfig, Document $doc)
{
// Iterate over all properties in the old configuration file and remove those that don't
// exist in the new config
foreach ($oldconfig->toArray() as $section => $directives) {
if (!is_array($directives)) {
Logger::warning('Section-less property ' . (string) $directives . ' was ignored.');
continue;
}
if ($newconfig->hasSection($section)) {
$newSection = $newconfig->getSection($section);
$oldDomSection = $doc->getSection($section);
foreach ($directives as $key => $value) {
if ($value instanceof ConfigObject) {
throw new ProgrammingError('Cannot diff recursive configs');
}
if (null === $newSection->get($key) && $oldDomSection->hasDirective($key)) {
$oldDomSection->removeDirective($key);
}
}
} else {
$doc->removeSection($section);
}
}
}