本文整理汇总了PHP中Icinga\Application\Config::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::fromArray方法的具体用法?PHP Config::fromArray怎么用?PHP Config::fromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Application\Config
的用法示例。
在下文中一共展示了Config::fromArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMoveBackend
public function testMoveBackend()
{
$config = Config::fromArray(array('test1' => '', 'test2' => '', 'test3' => ''));
$this->getRequestMock()->shouldReceive('getMethod')->andReturn('POST')->shouldReceive('isPost')->andReturn(true)->shouldReceive('getPost')->andReturn(array('backend_newpos' => 'test3|1'));
$form = new UserBackendReorderFormProvidingConfigFormWithoutSave();
$form->setIniConfig($config);
$form->setTokenDisabled();
$form->setUidDisabled();
$form->handleRequest();
$this->assertEquals(array('test1', 'test3', 'test2'), UserBackendConfigFormWithoutSave::$newConfig->keys(), 'Moving elements with UserBackendReorderForm does not seem to properly work');
}
示例2: apply
public function apply()
{
$config = array();
$config['security'] = $this->data['securityConfig'];
try {
Config::fromArray($config)->setConfigFile(Config::resolvePath('modules/monitoring/config.ini'))->saveIni();
} catch (Exception $e) {
$this->error = $e;
return false;
}
$this->error = false;
return true;
}
示例3: defineInitialAdmin
protected function defineInitialAdmin()
{
$config = array();
$config['admins'] = array('users' => $this->data['adminAccountData']['username'], 'permissions' => '*');
try {
Config::fromArray($config)->setConfigFile(Config::resolvePath('roles.ini'))->saveIni();
} catch (Exception $e) {
$this->permIniError = $e;
return false;
}
$this->permIniError = false;
return true;
}
示例4: createBackendsIni
protected function createBackendsIni()
{
$config = array();
$config[$this->data['backendConfig']['name']] = array('type' => $this->data['backendConfig']['type'], 'resource' => $this->data['resourceConfig']['name']);
try {
Config::fromArray($config)->setConfigFile(Config::resolvePath('modules/monitoring/backends.ini'))->saveIni();
} catch (Exception $e) {
$this->backendIniError = $e;
return false;
}
$this->backendIniError = false;
return true;
}
示例5: getResourceConfigs
/**
* Get the configuration of all existing resources, or all resources of the given type
*
* @param string $type Filter for resource type
*
* @return Config The resources configuration
*/
public static function getResourceConfigs($type = null)
{
self::assertResourcesExist();
if ($type === null) {
return self::$resources;
}
$resources = array();
foreach (self::$resources as $name => $resource) {
if ($resource->get('type') === $type) {
$resources[$name] = $resource;
}
}
return Config::fromArray($resources);
}
示例6: apply
public function apply()
{
$transportConfig = $this->data['transportConfig'];
$transportName = $transportConfig['name'];
unset($transportConfig['name']);
try {
Config::fromArray(array($transportName => $transportConfig))->setConfigFile(Config::resolvePath('modules/monitoring/commandtransports.ini'))->saveIni();
} catch (Exception $e) {
$this->error = $e;
return false;
}
$this->error = false;
return true;
}
示例7: 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();
}
示例8: apply
public function apply()
{
$config = array();
foreach ($this->data['generalConfig'] as $sectionAndPropertyName => $value) {
list($section, $property) = explode('_', $sectionAndPropertyName, 2);
$config[$section][$property] = $value;
}
if ($config['global']['config_backend'] === 'db') {
$config['global']['config_resource'] = $this->data['resourceName'];
}
try {
Config::fromArray($config)->setConfigFile(Config::resolvePath('config.ini'))->saveIni();
} catch (Exception $e) {
$this->error = $e;
return false;
}
$this->error = false;
return true;
}
示例9: createRolesIni
protected function createRolesIni()
{
if (isset($this->data['adminAccountData']['username'])) {
$config = array('users' => $this->data['adminAccountData']['username'], 'permissions' => '*');
if ($this->data['backendConfig']['backend'] === 'db') {
$config['groups'] = mt('setup', 'Administrators', 'setup.role.name');
}
} else {
// isset($this->data['adminAccountData']['groupname'])
$config = array('groups' => $this->data['adminAccountData']['groupname'], 'permissions' => '*');
}
try {
Config::fromArray(array(mt('setup', 'Administrators', 'setup.role.name') => $config))->setConfigFile(Config::resolvePath('roles.ini'))->saveIni();
} catch (Exception $e) {
$this->permIniError = $e;
return false;
}
$this->permIniError = false;
return true;
}
示例10: apply
public function apply()
{
$config = array();
foreach ($this->data['generalConfig'] as $sectionAndPropertyName => $value) {
list($section, $property) = explode('_', $sectionAndPropertyName);
$config[$section][$property] = $value;
}
$config['preferences']['store'] = $this->data['preferencesStore'];
if (isset($this->data['preferencesResource'])) {
$config['preferences']['resource'] = $this->data['preferencesResource'];
}
try {
Config::fromArray($config)->setConfigFile(Config::resolvePath('config.ini'))->saveIni();
} catch (Exception $e) {
$this->error = $e;
return false;
}
$this->error = false;
return true;
}
示例11: createGroupsIni
protected function createGroupsIni()
{
$config = array();
if (isset($this->data['groupConfig'])) {
$backendConfig = $this->data['groupConfig'];
$backendName = $backendConfig['name'];
unset($backendConfig['name']);
$config[$backendName] = $backendConfig;
} else {
$backendConfig = array('backend' => $this->data['backendConfig']['backend'], 'resource' => $this->data['resourceName']);
if ($backendConfig['backend'] === 'msldap') {
$backendConfig['user_backend'] = $this->data['backendConfig']['name'];
}
$config[$this->data['backendConfig']['name']] = $backendConfig;
}
try {
Config::fromArray($config)->setConfigFile(Config::resolvePath('groups.ini'))->saveIni();
} catch (Exception $e) {
$this->groupIniError = $e;
return false;
}
$this->groupIniError = false;
return true;
}
示例12: apply
public function apply()
{
$resourceConfig = array();
if (isset($this->data['dbResourceConfig'])) {
$dbConfig = $this->data['dbResourceConfig'];
$resourceName = $dbConfig['name'];
unset($dbConfig['name']);
$resourceConfig[$resourceName] = $dbConfig;
}
if (isset($this->data['ldapResourceConfig'])) {
$ldapConfig = $this->data['ldapResourceConfig'];
$resourceName = $ldapConfig['name'];
unset($ldapConfig['name']);
$resourceConfig[$resourceName] = $ldapConfig;
}
try {
Config::fromArray($resourceConfig)->setConfigFile(Config::resolvePath('resources.ini'))->saveIni();
} catch (Exception $e) {
$this->error = $e;
return false;
}
$this->error = false;
return true;
}
示例13: testExplicitRemove
public function testExplicitRemove()
{
$filename = tempnam(sys_get_temp_dir(), 'iw2');
$config = Config::fromArray(array('garbage' => array('foobar' => 'lolcat')));
$iniWriter = new IniWriter($config, $filename);
$iniWriter->write();
$section = $config->getSection('garbage');
$section->foobar = null;
$iniWriter = new IniWriter($config, $filename);
$this->assertNotContains('foobar', $iniWriter->render(), 'IniWriter doesn\'t remove section keys with null values');
unlink($filename);
}
示例14: getConfig
/**
* Create and return a Config object for this dashboard
*
* @return Config
*/
public function getConfig()
{
$output = array();
foreach ($this->panes as $pane) {
if ($pane->isUserWidget()) {
$output[$pane->getName()] = $pane->toArray();
}
foreach ($pane->getDashlets() as $dashlet) {
if ($dashlet->isUserWidget()) {
$output[$pane->getName() . '.' . $dashlet->getTitle()] = $dashlet->toArray();
}
}
}
return Config::fromArray($output)->setConfigFile($this->getConfigFile());
}
示例15: move
/**
* Move the given user backend up or down in order
*
* @param string $name The name of the backend to be moved
* @param int $position The new (absolute) position of the backend
*
* @return $this
*
* @throws InvalidArgumentException In case the backend does not exist
*/
public function move($name, $position)
{
if (!$name) {
throw new InvalidArgumentException($this->translate('User backend name missing'));
} elseif (!$this->config->hasSection($name)) {
throw new InvalidArgumentException($this->translate('Unknown user backend provided'));
}
$backendOrder = $this->config->keys();
array_splice($backendOrder, array_search($name, $backendOrder), 1);
array_splice($backendOrder, $position, 0, $name);
$newConfig = array();
foreach ($backendOrder as $backendName) {
$newConfig[$backendName] = $this->config->getSection($backendName);
}
$config = Config::fromArray($newConfig);
$this->config = $config->setConfigFile($this->config->getConfigFile());
return $this;
}