本文整理汇总了PHP中Icinga\Application\Config::fromIni方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::fromIni方法的具体用法?PHP Config::fromIni怎么用?PHP Config::fromIni使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Application\Config
的用法示例。
在下文中一共展示了Config::fromIni方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWhetherNestedPropertiesAreInserted
public function testWhetherNestedPropertiesAreInserted()
{
$target = $this->writeConfigToTemporaryFile('');
$config = Config::fromArray(array('a' => array('b' => 'c')));
$writer = new IniWriter($config, $target);
$writer->write();
$newConfig = Config::fromIni($target);
$this->assertInstanceOf('Icinga\\Data\\ConfigObject', $newConfig->getSection('a'), 'IniWriter does not insert nested properties');
$this->assertEquals('c', $newConfig->getSection('a')->get('b'), 'IniWriter does not insert nested properties');
}
示例2: render
/**
* Render the Zend_Config into a config filestring
*
* @return string
*/
public function render()
{
if (file_exists($this->filename)) {
$oldconfig = Config::fromIni($this->filename);
$content = trim(file_get_contents($this->filename));
} else {
$oldconfig = Config::fromArray(array());
$content = '';
}
$doc = IniParser::parseIni($content);
$this->diffPropertyUpdates($this->config, $doc);
$this->diffPropertyDeletions($oldconfig, $this->config, $doc);
$doc = $this->updateSectionOrder($this->config, $doc);
return $doc->render();
}
示例3: createResource
/**
* Create and return a resource based on the given configuration
*
* @param ConfigObject $config The configuration of the resource to create
*
* @return Selectable The resource
* @throws ConfigurationError In case of an unsupported type or invalid configuration
*/
public static function createResource(ConfigObject $config)
{
switch (strtolower($config->type)) {
case 'db':
$resource = new DbConnection($config);
break;
case 'ldap':
if (empty($config->root_dn)) {
throw new ConfigurationError('LDAP root DN missing');
}
$resource = new LdapConnection($config);
break;
case 'livestatus':
$resource = new LivestatusConnection($config->socket);
break;
case 'file':
$resource = new FileReader($config);
break;
case 'ini':
$resource = Config::fromIni($config->ini);
break;
default:
throw new ConfigurationError('Unsupported resource type "%s"', $config->type);
}
return $resource;
}
示例4: loadUserDashboards
/**
* @return bool
*/
private function loadUserDashboards()
{
try {
$config = Config::fromIni($this->getConfigFile());
} catch (NotReadableError $e) {
return;
}
if (!count($config)) {
return false;
}
$panes = array();
$dashlets = array();
foreach ($config as $key => $part) {
if (strpos($key, '.') === false) {
if ($this->hasPane($part->title)) {
$panes[$key] = $this->getPane($part->title);
} else {
$panes[$key] = new Pane($key);
$panes[$key]->setTitle($part->title);
}
$panes[$key]->setUserWidget();
if ((bool) $part->get('disabled', false) === true) {
$panes[$key]->setDisabled();
}
} else {
list($paneName, $dashletName) = explode('.', $key, 2);
$part->pane = $paneName;
$part->dashlet = $dashletName;
$dashlets[] = $part;
}
}
foreach ($dashlets as $dashletData) {
$pane = null;
if (array_key_exists($dashletData->pane, $panes) === true) {
$pane = $panes[$dashletData->pane];
} elseif (array_key_exists($dashletData->pane, $this->panes) === true) {
$pane = $this->panes[$dashletData->pane];
} else {
continue;
}
$dashlet = new DashboardDashlet($dashletData->title, $dashletData->url, $pane);
if ((bool) $dashletData->get('disabled', false) === true) {
$dashlet->setDisabled(true);
}
$dashlet->setUserWidget();
$pane->addDashlet($dashlet);
}
$this->mergePanes($panes);
return true;
}
示例5: loadNavigationConfig
/**
* Load and return this user's navigation configuration
*
* @return Config
*/
public function loadNavigationConfig()
{
return Config::fromIni(Config::resolvePath('preferences') . DIRECTORY_SEPARATOR . $this->getUsername() . DIRECTORY_SEPARATOR . 'navigation.ini');
}
示例6: testWhetherFromIniThrowsAnExceptionOnInsufficientPermission
/**
* @expectedException Icinga\Exception\NotReadableError
*/
public function testWhetherFromIniThrowsAnExceptionOnInsufficientPermission()
{
Config::fromIni('/etc/shadow');
}
示例7: testWhetherNestedPropertiesOfExtendingSectionsAreDeleted
/**
* @depends testWhetherNestedPropertiesOfExtendingSectionsAreInserted
*/
public function testWhetherNestedPropertiesOfExtendingSectionsAreDeleted()
{
$this->markTestSkipped('Implementation has changed. There is no "Extend" functionality anymore in our Config object');
$target = $this->writeConfigToTemporaryFile(<<<'EOD'
[foo]
a.b = "c"
[bar : foo]
d.e = "f"
EOD
);
$config = Config::fromArray(array('foo' => array('a' => array('b' => 'c')), 'bar' => array()));
$config->setExtend('bar', 'foo');
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
$writer->write();
$newConfig = Config::fromIni($target);
$this->assertNull($newConfig->get('bar')->get('d'), 'IniWriter does not delete nested properties of extending sections');
}