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


PHP Config::fromIni方法代码示例

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

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

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

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

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

示例6: testWhetherFromIniThrowsAnExceptionOnInsufficientPermission

 /**
  * @expectedException Icinga\Exception\NotReadableError
  */
 public function testWhetherFromIniThrowsAnExceptionOnInsufficientPermission()
 {
     Config::fromIni('/etc/shadow');
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:7,代码来源:ConfigTest.php

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


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