web/lib/Zend/Config/Writer/Ini.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    12  * obtain it through the world-wide-web, please send an email
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Config
    16  * @package    Zend_Config
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version    $Id: Ini.php 21983 2010-04-25 08:09:09Z jan $
    19  * @version    $Id: Ini.php 24593 2012-01-05 20:35:02Z matthew $
    20  */
    20  */
    21 
    21 
    22 /**
    22 /**
    23  * @see Zend_Config_Writer
    23  * @see Zend_Config_Writer
    24  */
    24  */
    25 require_once 'Zend/Config/Writer/FileAbstract.php';
    25 require_once 'Zend/Config/Writer/FileAbstract.php';
    26 
    26 
    27 /**
    27 /**
    28  * @category   Zend
    28  * @category   Zend
    29  * @package    Zend_Config
    29  * @package    Zend_Config
    30  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  */
    32  */
    33 class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract
    33 class Zend_Config_Writer_Ini extends Zend_Config_Writer_FileAbstract
    34 {
    34 {
    35     /**
    35     /**
   159             /** @see Zend_Config_Exception */
   159             /** @see Zend_Config_Exception */
   160             require_once 'Zend/Config/Exception.php';
   160             require_once 'Zend/Config/Exception.php';
   161             throw new Zend_Config_Exception('Value can not contain double quotes "');
   161             throw new Zend_Config_Exception('Value can not contain double quotes "');
   162         }
   162         }
   163     }
   163     }
   164     
   164 
   165     /**
   165     /**
   166      * Root elements that are not assigned to any section needs to be
   166      * Root elements that are not assigned to any section needs to be
   167      * on the top of config.
   167      * on the top of config.
   168      * 
   168      *
   169      * @see    http://framework.zend.com/issues/browse/ZF-6289
   169      * @see    http://framework.zend.com/issues/browse/ZF-6289
   170      * @param  Zend_Config
   170      * @param  Zend_Config
   171      * @return Zend_Config
   171      * @return Zend_Config
   172      */
   172      */
   173     protected function _sortRootElements(Zend_Config $config)
   173     protected function _sortRootElements(Zend_Config $config)
   174     {
   174     {
   175         $configArray = $config->toArray();
   175         $configArray = $config->toArray();
   176         $sections = array();
   176         $sections = array();
   177         
   177 
   178         // remove sections from config array
   178         // remove sections from config array
   179         foreach ($configArray as $key => $value) {
   179         foreach ($configArray as $key => $value) {
   180             if (is_array($value)) {
   180             if (is_array($value)) {
   181                 $sections[$key] = $value;
   181                 $sections[$key] = $value;
   182                 unset($configArray[$key]);
   182                 unset($configArray[$key]);
   183             }
   183             }
   184         }
   184         }
   185         
   185 
   186         // readd sections to the end
   186         // readd sections to the end
   187         foreach ($sections as $key => $value) {
   187         foreach ($sections as $key => $value) {
   188             $configArray[$key] = $value;
   188             $configArray[$key] = $value;
   189         }
   189         }
   190         
   190 
   191         return new Zend_Config($configArray);
   191         return new Zend_Config($configArray);
   192     }
   192     }
   193 }
   193 }