当前位置: 首页>>代码示例>>PHP>>正文


PHP Config::setSection方法代码示例

本文整理汇总了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;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:15,代码来源:AuthBackendPage.php

示例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;
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:13,代码来源:UserGroupBackendPage.php

示例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;
     }
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:23,代码来源:ConfigForm.php

示例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());
     }
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:49,代码来源:IniRepository.php

示例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');
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:10,代码来源:ConfigTest.php

示例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;
 }
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:24,代码来源:AdminAccountPage.php


注:本文中的Icinga\Application\Config::setSection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。