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


PHP Zend_Config::readOnly方法代码示例

本文整理汇总了PHP中Zend_Config::readOnly方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Config::readOnly方法的具体用法?PHP Zend_Config::readOnly怎么用?PHP Zend_Config::readOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Config的用法示例。


在下文中一共展示了Zend_Config::readOnly方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setDefaultRoute

 /**
  * Sets the default route according to the configuration data provided in $config.
  * Two settings are required: the route prefix (key: routePrefix),
  * and the controller class-name (key: controllerClass).
  *
  * Three optional settings are supported as well: major section (key: majorSection),
  * minor section (key: minorSection) and request parameters (key: params);
  * which might be used during the routing process.
  *
  * @param Zend_Config $config Configuration data
  * @param array $dependencyData Data array supplied by the "init_dependencies" event
  * @throws XenForo_Exception
  */
 public static function setDefaultRoute(Zend_Config $config, array $dependencyData)
 {
     $routesPublic = $dependencyData['routesPublic'];
     if (!$config->routePrefix || !$config->controllerClass) {
         // Debugging message. No need for phrasing.
         throw new XenForo_Exception('Missing route-prefix and/or controller class-name.');
     }
     if ($config->readOnly()) {
         // A read-only object was passed. Arghh!
         $newConfig = new Zend_Config(array('routeClass' => $routesPublic[$config->routePrefix]['route_class']), true);
         $config = $newConfig->merge($config);
     } else {
         $config->routeClass = $routesPublic[$config->routePrefix]['route_class'];
     }
     self::_setCustomRoutePrefixes($config->routePrefix, $routesPublic);
     $config->setReadOnly();
     XenForo_Application::set('customIndex', $config);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:31,代码来源:Index.php

示例2: mergeConfigs

 /**
  * Diesen Merge sollte eigentlich das Zend machen, aber das merged nicht so
  * wie wir das erwarten. Beispiel:
  *
  * Main Config:
  * bla.blubb[] = x
  * bla.blubb[] = y
  * bla.blubb[] = z
  *
  * Merge Config:
  * bla.blubb[] = a
  * bla.blubb[] = b
  *
  * Nach den Config-Section regeln würde man erwarten, dass nach dem mergen nur mehr
  * a und b drin steht. Tatsächlich merget Zend aber so, dass a, b, z überbleibt.
  * Zend überschreibt die Werte, was wir nicht wollen, deshalb dieses
  * händische mergen hier.
  */
 public static function mergeConfigs(Zend_Config $main, Zend_Config $merge)
 {
     // check if all keys are of type 'integer' and if so, only use merge config
     $everyKeyIsInteger = true;
     foreach ($merge as $key => $item) {
         if (!is_int($key)) {
             $everyKeyIsInteger = false;
             break;
         }
     }
     if ($everyKeyIsInteger) {
         return $merge;
     }
     foreach ($merge as $key => $item) {
         if (isset($main->{$key})) {
             if ($item instanceof Zend_Config && $main->{$key} instanceof Zend_Config) {
                 $main->{$key} = Kwf_Config_Web::mergeConfigs($main->{$key}, new Zend_Config($item->toArray(), !$main->readOnly()));
             } else {
                 $main->{$key} = $item;
             }
         } else {
             if ($item instanceof Zend_Config) {
                 $main->{$key} = new Zend_Config($item->toArray(), !$main->readOnly());
             } else {
                 $main->{$key} = $item;
             }
         }
     }
     return $main;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:48,代码来源:Web.php

示例3: testSetReadOnlyAppliesToChildren

 /**
  * @group ZF-4728
  *
  */
 public function testSetReadOnlyAppliesToChildren()
 {
     $config = new Zend_Config($this->_all, true);
     $config->setReadOnly();
     $this->assertTrue($config->readOnly());
     $this->assertTrue($config->one->readOnly(), 'First level children are writable');
     $this->assertTrue($config->one->two->readOnly(), 'Second level children are writable');
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:12,代码来源:ConfigTest.php

示例4: setValueInConfig

 /**
  * Updates a value in a Zend_Config object.
  *
  * @param Zend_Config $config
  * @param $option Name of option
  * @param $value New value
  * @throws Zend_Exception
  */
 public static function setValueInConfig(Zend_Config $config, $option, $value)
 {
     if ($config->readOnly()) {
         Zend_Registry::get('Zend_Log')->err('Zend_Config object is readonly.');
         return;
     }
     $keys = explode('.', $option);
     $subconfig = $config;
     $index = 0;
     foreach ($keys as $key) {
         $index++;
         if (is_null($subconfig->get($key)) && $index < count($keys)) {
             // create subsection
             eval('$subconfig->' . $key . ' = array();');
             $subconfig = $subconfig->get($key);
         } else {
             // set value
             eval('$subconfig->' . $key . ' = $value;');
         }
     }
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:29,代码来源:Configuration.php


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