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


PHP Zend_Config::__construct方法代码示例

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


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

示例1: __construct

 /**
  * Loads the section $section from the config file $filename for
  * access facilitated by nested object properties.
  *
  * Sections are defined in the XML as children of the root element.
  *
  * In order to extend another section, a section defines the "extends"
  * attribute having a value of the section name from which the extending
  * section inherits values.
  *
  * Note that the keys in $section will override any keys of the same
  * name in the sections that have been included via "extends".
  *
  * @param  string  $filename
  * @param  mixed   $section
  * @param  boolean $allowModifications
  * @throws Zend_Config_Exception
  * @return void
  */
 public function __construct($filename, $section = null, $allowModifications = false)
 {
     if (empty($filename)) {
         throw new Zend_Config_Exception('Filename is not set');
     }
     $config = simplexml_load_file($filename);
     if (null === $section) {
         $dataArray = array();
         foreach ($config as $sectionName => $sectionData) {
             $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
         }
         parent::__construct($dataArray, $allowModifications);
     } elseif (is_array($section)) {
         $dataArray = array();
         foreach ($section as $sectionName) {
             if (!isset($config->{$sectionName})) {
                 throw new Zend_Config_Exception("Section '{$sectionName}' cannot be found in {$filename}");
             }
             $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
         }
         parent::__construct($dataArray, $allowModifications);
     } else {
         if (!isset($config->{$section})) {
             throw new Zend_Config_Exception("Section '{$section}' cannot be found in {$filename}");
         }
         $dataArray = $this->_processExtends($config, $section);
         if (!is_array($dataArray)) {
             // section in the XML file contains just one top level string
             $dataArray = array($section => $dataArray);
         }
         parent::__construct($dataArray, $allowModifications);
     }
     $this->_loadedSection = $section;
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:53,代码来源:Xml.php

示例2: __construct

 public function __construct($config = null, $type = 'array', $allowModifications = true)
 {
     parent::__construct(array(), $allowModifications);
     if (!is_null($config)) {
         $this->append($config, $type);
     }
 }
开发者ID:nurikk,项目名称:EvilRocketFramework,代码行数:7,代码来源:Config.php

示例3: __construct

 public function __construct($string, $section = null, $options = false)
 {
     if (empty($string)) {
         /**
          * @see Zend_Config_Exception
          */
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception('String is not set');
     }
     $allowModifications = false;
     if (is_bool($options)) {
         $allowModifications = $options;
     } elseif (is_array($options)) {
         if (isset($options['allowModifications'])) {
             $allowModifications = (bool) $options['allowModifications'];
         }
         if (isset($options['nestSeparator'])) {
             $this->_nestSeparator = (string) $options['nestSeparator'];
         }
         if (isset($options['skipExtends'])) {
             $this->_skipExtends = (bool) $options['skipExtends'];
         }
     }
     $iniArray = $this->_loadIniFile($string);
     if (null === $section) {
         // Load entire file
         $dataArray = array();
         foreach ($iniArray as $sectionName => $sectionData) {
             if (!is_array($sectionData)) {
                 $dataArray = $this->_arrayMergeRecursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData));
             } else {
                 $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName);
             }
         }
         parent::__construct($dataArray, $allowModifications);
     } else {
         // Load one or more sections
         if (!is_array($section)) {
             $section = array($section);
         }
         $dataArray = array();
         foreach ($section as $sectionName) {
             if (!isset($iniArray[$sectionName])) {
                 /**
                  * @see Zend_Config_Exception
                  */
                 require_once 'Zend/Config/Exception.php';
                 throw new Zend_Config_Exception("Section '{$sectionName}' cannot be found in {$string}");
             }
             $dataArray = $this->_arrayMergeRecursive($this->_processSection($iniArray, $sectionName), $dataArray);
         }
         parent::__construct($dataArray, $allowModifications);
     }
     $this->_loadedSection = $section;
 }
开发者ID:hausdesign,项目名称:zf-library,代码行数:55,代码来源:Ini.php

示例4: __construct

 /**
  * Open and validate a config file.
  *
  * uses CONFIG_PARTYCAL_MODE_EXCEPTIONS and CONFIG_PARTYCAL_MODE_STDERR to 
  * throw exceptions or output errors
  *
  * @throws Config_Exception_PartyCal
  *
  * @param $node String needed node
  * @param $mode Long mode for error handling, Exceptions are default
  *
  * @todo implement Exception/sdterr handling
  */
 public function __construct($node, $mode = NULL)
 {
     parent::__construct(new Zend_Config_Ini($_ENV['PARTYCAL_CONFIG'], $node));
     $config_validator = new Config_Validator_PartyCal($_ENV['PARTYCAL_CONFIG'], CONFIG_VALIDATOR_PARTYCAL_MODE_SCAN);
     try {
         $config_validator->validate();
     } catch (Exception $e) {
         //check mode
         //write to stderr
     }
 }
开发者ID:BackupTheBerlios,项目名称:partycal-svn,代码行数:24,代码来源:Config.php

示例5: __construct

 public final function __construct()
 {
     $backtrace = debug_backtrace();
     $class = $backtrace[1]['class'];
     if ($class !== get_class($this)) {
         throw new RuntimeException('Não permitida chamada externa');
     }
     $method = strtolower($backtrace[1]['function']);
     if ($method !== 'getinstance') {
         throw new RuntimeException('Não permitida chamada externa');
     }
     parent::__construct(array(), TRUE);
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:13,代码来源:Configuration.php

示例6: __construct

 /**
  * Class constructor
  * @var array|Zend_Config
  */
 public function __construct($config)
 {
     if (is_array($config)) {
         $config = new Zend_Config($config);
     }
     if (!$config instanceof Zend_Config) {
         throw new Zend_Config_Exception('Config must be an array or Zend_Config');
     }
     parent::__construct(array(), true);
     $this->merge($config);
     $this->_processPlaceholders($this);
     $this->setReadOnly();
 }
开发者ID:kandy,项目名称:system,代码行数:17,代码来源:Placeholder.php

示例7: __construct

 /**
  * Prüft das Vorhandensein der Einstellungsdatei und lädt diese
  * @param string $filename
  * @throws InvalidArgumentException
  */
 public function __construct($filename)
 {
     if (Zend_Registry::isRegistered('Dragon_Repository_Registry')) {
         foreach (array_reverse(Zend_Registry::get('Dragon_Repository_Registry')->getRepositories()) as $repositoryname => $directorypath) {
             $filepath = $directorypath . '/config/' . $filename . '.php';
             if (is_file($filepath)) {
                 parent::__construct(require $filepath);
                 return;
             }
         }
     }
     $filepath = DRAGONJSONSERVER_PATH . '/config/' . $filename . '.php';
     if (!is_file($filepath)) {
         throw new Dragon_Application_Exception_System('incorrect configfile', array('filename' => $filename));
     }
     parent::__construct(require $filepath);
 }
开发者ID:dragonprojects,项目名称:dragonjsonserver,代码行数:22,代码来源:Config.php

示例8: __construct

 public function __construct($name, $config = null)
 {
     $this->name = $name;
     $this->config = $config;
     try {
         $this->basedir = Zend_Registry::get('config_basedir');
     } catch (Zend_Exception $e) {
         $this->basedir = 'private/config/';
     }
     $this->filename = $this->basedir . $name . '.php';
     if ($config === null) {
         if (file_exists($this->filename)) {
             /* Ne pas utiliser include, car le cache d'include fausse
                certains cas, notamment à l'installation. */
             $php = str_replace('<?php', '', file_get_contents($this->filename));
             $config = eval($php);
         }
         if (!is_array($config)) {
             $config = array();
         }
     }
     parent::__construct($config, true);
 }
开发者ID:bersace,项目名称:strass,代码行数:23,代码来源:Php.php

示例9: __construct

 /**
  * Loads the section $section from the config file encoded as JSON
  *
  * Sections are defined as properties of the main object
  *
  * In order to extend another section, a section defines the "_extends"
  * property having a value of the section name from which the extending
  * section inherits values.
  *
  * Note that the keys in $section will override any keys of the same
  * name in the sections that have been included via "_extends".
  *
  * @param  string  $json     JSON file or string to process
  * @param  mixed   $section Section to process
  * @param  boolean $options Whether modifiacations are allowed at runtime
  * @throws Zend_Config_Exception When JSON text is not set or cannot be loaded
  * @throws Zend_Config_Exception When section $sectionName cannot be found in $json
  */
 public function __construct($json, $section = null, $options = false)
 {
     if (empty($json)) {
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception('Filename is not set');
     }
     $allowModifications = false;
     if (is_bool($options)) {
         $allowModifications = $options;
     } elseif (is_array($options)) {
         foreach ($options as $key => $value) {
             switch (strtolower($key)) {
                 case 'allow_modifications':
                 case 'allowmodifications':
                     $allowModifications = (bool) $value;
                     break;
                 case 'skip_extends':
                 case 'skipextends':
                     $this->_skipExtends = (bool) $value;
                     break;
                 case 'ignore_constants':
                 case 'ignoreconstants':
                     $this->_ignoreConstants = (bool) $value;
                     break;
                 default:
                     break;
             }
         }
     }
     set_error_handler(array($this, '_loadFileErrorHandler'));
     // Warnings and errors are suppressed
     if ($json[0] != '{') {
         $json = file_get_contents($json);
     }
     restore_error_handler();
     // Check if there was a error while loading file
     if ($this->_loadFileErrorStr !== null) {
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception($this->_loadFileErrorStr);
     }
     // Replace constants
     if (!$this->_ignoreConstants) {
         $json = $this->_replaceConstants($json);
     }
     // Parse/decode
     try {
         $config = Zend_Json::decode($json);
     } catch (Zend_Json_Exception $e) {
         // decode failed
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception("Error parsing JSON data");
     }
     if ($section === null) {
         $dataArray = array();
         foreach ($config as $sectionName => $sectionData) {
             $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
         }
         parent::__construct($dataArray, $allowModifications);
     } elseif (is_array($section)) {
         $dataArray = array();
         foreach ($section as $sectionName) {
             if (!isset($config[$sectionName])) {
                 require_once 'Zend/Config/Exception.php';
                 throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $sectionName));
             }
             $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
         }
         parent::__construct($dataArray, $allowModifications);
     } else {
         if (!isset($config[$section])) {
             require_once 'Zend/Config/Exception.php';
             throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $section));
         }
         $dataArray = $this->_processExtends($config, $section);
         if (!is_array($dataArray)) {
             // Section in the JSON data contains just one top level string
             $dataArray = array($section => $dataArray);
         }
         parent::__construct($dataArray, $allowModifications);
     }
     $this->_loadedSection = $section;
 }
开发者ID:Cryde,项目名称:sydney-core,代码行数:100,代码来源:Json.php

示例10: __construct

 public function __construct($node)
 {
     parent::__construct(new Zend_Config_Ini($_ENV['PARTYCAL_CONFIG'], $node));
 }
开发者ID:BackupTheBerlios,项目名称:partycal-svn,代码行数:4,代码来源:Config_PartyCal.php

示例11: __construct

 /**
  * Loads the section $section from the config file $filename for
  * access facilitated by nested object properties.
  *
  * If any keys with $section are called "extends", then the section
  * pointed to by the "extends" is then included into the properties.
  * Note that the keys in $section will override any keys of the same
  * name in the sections that have been included via "extends".
  *
  * If any key includes a ".", then this will act as a separator to
  * create a sub-property.
  *
  * example ini file:
  *      [all]
  *      db.connection = database
  *      hostname = live
  *
  *      [staging]
  *      extends = all
  *      hostname = staging
  *
  * after calling $data = new Zend_Config_Ini($file, 'staging'); then
  *      $data->hostname === "staging"
  *      $data->db->connection === "database"
  *
  * @param string $filename
  * @param mixed $section
  * @param boolean $allowModifications
  * @throws Zend_Config_Exception
  */
 public function __construct($filename, $section, $allowModifications = false)
 {
     if (empty($filename)) {
         throw new Zend_Config_Exception('Filename is not set');
     }
     $iniArray = parse_ini_file($filename, true);
     $preProcessedArray = array();
     foreach ($iniArray as $key => $data) {
         $bits = explode(':', $key);
         $numberOfBits = count($bits);
         $thisSection = trim($bits[0]);
         switch (count($bits)) {
             case 1:
                 $preProcessedArray[$thisSection] = $data;
                 break;
             case 2:
                 $extendedSection = trim($bits[1]);
                 $preProcessedArray[$thisSection] = array_merge(array(';extends' => $extendedSection), $data);
                 break;
             default:
                 throw new Zend_Config_Exception("Section '{$thisSection}' may not extend multiple sections in {$filename}");
         }
     }
     if (null === $section) {
         $dataArray = array();
         foreach ($preProcessedArray as $sectionName => $sectionData) {
             $dataArray[$sectionName] = $this->_processExtends($preProcessedArray, $sectionName);
         }
         parent::__construct($dataArray, $allowModifications);
     } elseif (is_array($section)) {
         $dataArray = array();
         foreach ($section as $sectionName) {
             if (!isset($preProcessedArray[$sectionName])) {
                 throw new Zend_Config_Exception("Section '{$sectionName}' cannot be found in {$filename}");
             }
             $dataArray = array_merge($this->_processExtends($preProcessedArray, $sectionName), $dataArray);
         }
         parent::__construct($dataArray, $allowModifications);
     } else {
         if (!isset($preProcessedArray[$section])) {
             throw new Zend_Config_Exception("Section '{$section}' cannot be found in {$filename}");
         }
         parent::__construct($this->_processExtends($preProcessedArray, $section), $allowModifications);
     }
     $this->_loadedSection = $section;
 }
开发者ID:fferriere,项目名称:web,代码行数:76,代码来源:Ini.php

示例12: __construct

    /**
     * Loads the section $section from the config file $filename for
     * access facilitated by nested object properties.
     *
     * If the section name contains a ":" then the section name to the right
     * is loaded and included into the properties. Note that the keys in
     * this $section will override any keys of the same
     * name in the sections that have been included via ":".
     *
     * If the $section is null, then all sections in the ini file are loaded.
     *
     * If any key includes a ".", then this will act as a separator to
     * create a sub-property.
     *
     * example ini file:
     *      [all]
     *      db.connection = database
     *      hostname = live
     *
     *      [staging : all]
     *      hostname = staging
     *
     * after calling $data = new Zend_Config_Ini($file, 'staging'); then
     *      $data->hostname === "staging"
     *      $data->db->connection === "database"
     *
     * The $config parameter may be provided as either a boolean or an array.
     * If provided as a boolean, this sets the $allowModifications option of
     * Zend_Config. If provided as an array, there are two configuration
     * directives that may be set. For example:
     *
     * $config = array(
     *     'allowModifications' => false,
     *     'nestSeparator'      => '->'
     *      );
     *
     * @param  string        $filename
     * @param  string|null   $section
     * @param  boolean|array $config
     * @throws Zend_Config_Exception
     */
    public function __construct($filename, $section = null, $config = false)
    {
        if (empty($filename)) {
            /** @see Zend_Config_Exception */
            require_once 'Zend/Config/Exception.php';
            throw new Zend_Config_Exception('Filename is not set');
        }

        $allowModifications = false;
        if (is_bool($config)) {
            $allowModifications = $config;
        } elseif (is_array($config)) {
            if (isset($config['allowModifications'])) {
                $allowModifications = (bool) $config['allowModifications'];
            }
            if (isset($config['nestSeparator'])) {
                $this->_nestSeparator = (string) $config['nestSeparator'];
            }
        }

        $iniArray = parse_ini_file($filename, true);
        $preProcessedArray = array();
        foreach ($iniArray as $key => $data)
        {
            $bits = explode(':', $key);
            $numberOfBits = count($bits);
            $thisSection = trim($bits[0]);
            switch (count($bits)) {
                case 1:
                    $preProcessedArray[$thisSection] = $data;
                    break;

                case 2:
                    $extendedSection = trim($bits[1]);
                    $preProcessedArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data);
                    break;

                default:
                    /** @see Zend_Config_Exception */
                    require_once 'Zend/Config/Exception.php';
                    throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections in $filename");
            }
        }

        if (null === $section) {
            $dataArray = array();
            foreach ($preProcessedArray as $sectionName => $sectionData) {
                $dataArray[$sectionName] = $this->_processExtends($preProcessedArray, $sectionName);
            }
            parent::__construct($dataArray, $allowModifications);
        } elseif (is_array($section)) {
            $dataArray = array();
            foreach ($section as $sectionName) {
                if (!isset($preProcessedArray[$sectionName])) {
                    /** @see Zend_Config_Exception */
                    require_once 'Zend/Config/Exception.php';
                    throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $filename");
                }
                $dataArray = array_merge($this->_processExtends($preProcessedArray, $sectionName), $dataArray);
//.........这里部分代码省略.........
开发者ID:jorgenils,项目名称:zend-framework,代码行数:101,代码来源:Ini.php

示例13: __construct

 /**
  * Loads the section $section from the config file $filename for
  * access facilitated by nested object properties.
  *
  * If the section name contains a ":" then the section name to the right
  * is loaded and included into the properties. Note that the keys in
  * this $section will override any keys of the same name in the sections 
  * that have been included via ":".
  *
  * If the $section is null, then all sections in the ini file are loaded.
  *
  * If any key includes a ".", then this will act as a separator to create 
  * a sub-property.
  *
  * example ini file:
  *      [all]
  *      db.connection = database
  *      hostname = live
  *
  *      [staging : all]
  *      hostname = staging
  *
  * after calling $data = new Zend_Config_Ini($file, 'staging'); then
  *      $data->hostname === "staging"
  *      $data->db->connection === "database"
  *
  * The $options parameter may be provided as either a boolean or an array.
  * If provided as a boolean, this sets the $allowModifications option of
  * Zend_Config. If provided as an array, there are two configuration
  * directives that may be set. For example:
  *
  * $options = array(
  *     'allowModifications' => false,
  *     'nestSeparator'      => '->'
  *      );
  *
  * @param  string        $filename
  * @param  string|null   $section
  * @param  boolean|array $options
  * @throws Zend_Config_Exception
  */
 public function __construct($filename, $section = null, $options = false)
 {
     if (empty($filename)) {
         /** @see Zend_Config_Exception */
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception('Filename is not set');
     }
     // process $options
     $allowModifications = false;
     if (is_bool($options)) {
         $allowModifications = $options;
     } elseif (is_array($options)) {
         if (isset($options['allowModifications'])) {
             $allowModifications = (bool) $options['allowModifications'];
         }
         if (isset($options['nestSeparator'])) {
             $this->_nestSeparator = (string) $options['nestSeparator'];
         }
     }
     $iniArray = $this->_loadIniFile($filename);
     if (null === $section) {
         // Load entire file
         $config = $this->_loadAllSections($iniArray);
     } elseif (is_array($section)) {
         // Load multiple sections
         $config = array();
         foreach ($section as $sectionName) {
             $config = array_merge($this->_loadSection($iniArray, $sectionName), $config);
         }
     } else {
         // Load single section
         $config = $this->_loadSection($iniArray, $section);
     }
     parent::__construct($config, $allowModifications);
     // Set _loadedSection after calling parent's constructor as it
     // will initialize it to null
     $this->_loadedSection = $section;
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:79,代码来源:Ini-zf2849-1.php

示例14: __construct

    /**
     * Loads the section $section from the config file $filename for
     * access facilitated by nested object properties.
     *
     * Sections are defined in the XML as children of the root element.
     *
     * In order to extend another section, a section defines the "extends"
     * attribute having a value of the section name from which the extending
     * section inherits values.
     *
     * Note that the keys in $section will override any keys of the same
     * name in the sections that have been included via "extends".
     *
     * @param  string  $filename
     * @param  mixed   $section
     * @param  boolean $allowModifications
     * @throws Zend_Config_Exception
     * @return void
     */
    public function __construct($filename, $section = null, $allowModifications = false)
    {
        if (empty($filename)) {
            /**
             * @see Zend_Config_Exception
             */
            require_once 'Zend/Config/Exception.php';
            throw new Zend_Config_Exception('Filename is not set');
        }
        $old_error_handler = set_error_handler(array(__CLASS__, 'simplexmlLoadFileFileErrorHandler'));
        $config = simplexml_load_file($filename);
        restore_error_handler();

        if (null === $section) {
            $dataArray = array();
            foreach ($config as $sectionName => $sectionData) {
                $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
            }
            parent::__construct($dataArray, $allowModifications);
        } elseif (is_array($section)) {
            $dataArray = array();
            foreach ($section as $sectionName) {
                if (!isset($config->$sectionName)) {
                    /**
                     * @see Zend_Config_Exception
                     */
                    require_once 'Zend/Config/Exception.php';
                    throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $filename");
                }
                $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
            }
            parent::__construct($dataArray, $allowModifications);
        } else {
            if (!isset($config->$section)) {
                /**
                 * @see Zend_Config_Exception
                 */
                require_once 'Zend/Config/Exception.php';
                throw new Zend_Config_Exception("Section '$section' cannot be found in $filename");
            }
            $dataArray = $this->_processExtends($config, $section);
            if(!is_array($dataArray)) {
                // section in the XML file contains just one top level string
                $dataArray = array($section=>$dataArray);
            }
            parent::__construct($dataArray, $allowModifications);
        }

        $this->_loadedSection = $section;
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:69,代码来源:Xml.php

示例15: __construct

 /**
  * Loads the section $section from the config file encoded as JSON
  *
  * Sections are defined as properties of the main object
  *
  * In order to extend another section, a section defines the "_extends"
  * property having a value of the section name from which the extending
  * section inherits values.
  *
  * Note that the keys in $section will override any keys of the same
  * name in the sections that have been included via "_extends".
  *
  * @param  string  $json     JSON file or string to process
  * @param  mixed   $section Section to process
  * @param  boolean $options Whether modifiacations are allowed at runtime
  * @throws Zend_Config_Exception When JSON text is not set or cannot be loaded
  * @throws Zend_Config_Exception When section $sectionName cannot be found in $json
  */
 public function __construct($json, $section = null, $options = false)
 {
     if (empty($json)) {
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception('Filename is not set');
     }
     $allowModifications = false;
     if (is_bool($options)) {
         $allowModifications = $options;
     } elseif (is_array($options)) {
         if (isset($options['allowModifications'])) {
             $allowModifications = (bool) $options['allowModifications'];
         }
         if (isset($options['skipExtends'])) {
             $this->_skipExtends = (bool) $options['skipExtends'];
         }
     }
     set_error_handler(array($this, '_loadFileErrorHandler'));
     // Warnings and errors are suppressed
     if ($json[0] != '{') {
         $json = file_get_contents($json);
     }
     restore_error_handler();
     // Check if there was a error while loading file
     if ($this->_loadFileErrorStr !== null) {
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception($this->_loadFileErrorStr);
     }
     $config = Zend_Json::decode($json);
     if ($config == null) {
         // decode failed
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception("Error parsing JSON data");
     }
     if ($section === null) {
         $dataArray = array();
         foreach ($config as $sectionName => $sectionData) {
             $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
         }
         parent::__construct($dataArray, $allowModifications);
     } else {
         if (is_array($section)) {
             $dataArray = array();
             foreach ($section as $sectionName) {
                 if (!isset($config->{$sectionName})) {
                     require_once 'Zend/Config/Exception.php';
                     throw new Zend_Config_Exception("Section '{$sectionName}' cannot be found in the data");
                 }
                 $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
             }
             parent::__construct($dataArray, $allowModifications);
         } else {
             if (!isset($config[$section])) {
                 require_once 'Zend/Config/Exception.php';
                 throw new Zend_Config_Exception("Section '{$section}' cannot be found in the data");
             }
             $dataArray = $this->_processExtends($config, $section);
             if (!is_array($dataArray)) {
                 // Section in the JSON data contains just one top level string
                 $dataArray = array($section => $dataArray);
             }
             parent::__construct($dataArray, $allowModifications);
         }
     }
     $this->_loadedSection = $section;
 }
开发者ID:jtietema,项目名称:Fizzy,代码行数:84,代码来源:Json.php


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