本文整理汇总了PHP中Icinga\Application\Config::setSection方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::setSection方法的具体用法?PHP Config::setSection怎么用?PHP Config::setSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Application\Config
的用法示例。
在下文中一共展示了Config::setSection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setResourceConfig
/**
* Set the resource configuration to use
*
* @param array $config
*
* @return $this
*/
public function setResourceConfig(array $config)
{
$resourceConfig = new Config();
$resourceConfig->setSection($config['name'], $config);
ResourceFactory::setConfig($resourceConfig);
$this->config = $config;
return $this;
}
示例2: createBackendConfiguration
/**
* Return the user backend configuration as Config object
*
* @return Config
*/
protected function createBackendConfiguration()
{
$config = new Config();
$backendConfig = $this->backendConfig;
$backendConfig['resource'] = $this->resourceConfig['name'];
$config->setSection($this->backendConfig['name'], $backendConfig);
return $config;
}
示例3: onSuccess
/**
* {@inheritdoc}
*/
public function onSuccess()
{
$sections = array();
foreach ($this->getValues() as $sectionAndPropertyName => $value) {
if ($value === '') {
$value = null;
// Causes the config writer to unset it
}
list($section, $property) = explode('_', $sectionAndPropertyName, 2);
$sections[$section][$property] = $value;
}
foreach ($sections as $section => $config) {
$this->config->setSection($section, $config);
}
if ($this->save()) {
Notification::success($this->translate('New configuration has successfully been stored'));
} else {
return false;
}
}
示例4: update
/**
* Update the target with the given data and optionally limit the affected entries by using a filter
*
* @param string $target
* @param array $data
* @param Filter $filter
*
* @throws StatementException In case the operation has failed
*/
public function update($target, array $data, Filter $filter = null)
{
$newData = $this->requireStatementColumns($target, $data);
$keyColumn = $this->ds->getConfigObject()->getKeyColumn();
if ($filter === null && isset($newData[$keyColumn])) {
throw new StatementException(t('Cannot update. Column "%s" holds a section\'s name which must be unique'), $keyColumn);
}
if ($filter !== null) {
$filter = $this->requireFilter($target, $filter);
}
$newSection = null;
foreach (iterator_to_array($this->ds) as $section => $config) {
if ($filter !== null && !$filter->matches($config)) {
continue;
}
if ($newSection !== null) {
throw new StatementException(t('Cannot update. Column "%s" holds a section\'s name which must be unique'), $keyColumn);
}
foreach ($newData as $column => $value) {
if ($column === $keyColumn) {
$newSection = $value;
} else {
$config->{$column} = $value;
}
}
if ($newSection) {
if ($this->ds->hasSection($newSection)) {
throw new StatementException(t('Cannot update. Section "%s" does already exist'), $newSection);
}
$this->ds->removeSection($section)->setSection($newSection, $config);
} else {
$this->ds->setSection($section, $config);
}
}
try {
$this->ds->saveIni();
} catch (Exception $e) {
throw new StatementException(t('Failed to update. An error occurred: %s'), $e->getMessage());
}
}
示例5: testWhetherConfigKnowsWhichSectionsItHas
/**
* @depends testWhetherConfigSetsSingleSections
*/
public function testWhetherConfigKnowsWhichSectionsItHas()
{
$config = new Config();
$config->setSection('a');
$this->assertTrue($config->hasSection('a'), 'Config::hasSection does not know anything about its sections');
$this->assertFalse($config->hasSection('b'), 'Config::hasSection does not know anything about its sections');
}
示例6: createUserGroupBackend
/**
* Create and return the user group backend
*
* @return LdapUserGroupBackend
*/
protected function createUserGroupBackend()
{
$resourceConfig = new Config();
$resourceConfig->setSection($this->resourceConfig['name'], $this->resourceConfig);
ResourceFactory::setConfig($resourceConfig);
$backendConfig = new Config();
$backendConfig->setSection($this->backendConfig['name'], array_merge($this->backendConfig, array('resource' => $this->resourceConfig['name'])));
UserBackend::setConfig($backendConfig);
if (empty($this->groupConfig)) {
$groupConfig = new ConfigObject(array('backend' => $this->backendConfig['backend'], 'resource' => $this->resourceConfig['name'], 'user_backend' => $this->backendConfig['name']));
} else {
$groupConfig = new ConfigObject($this->groupConfig);
}
$backend = UserGroupBackend::create(null, $groupConfig);
if (!$backend instanceof Selectable) {
throw new NotImplementedError('Unsupported, until #9772 has been resolved');
}
return $backend;
}