Zend_Config_Exception example

if ($branchType === null) {
                if (is_numeric($key)) {
                    $branchType = 'numeric';
                    $branchName = $xml->getName();
                    $xml        = $parent;

                    unset($parent->{$branchName});
                } else {
                    $branchType = 'string';
                }
            } else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
                throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
            }

            if ($branchType === 'numeric') {
                if ($value instanceof Zend_Config) {
                    $child = $parent->addChild($branchName);

                    $this->_addBranch($value$child$parent);
                } else {
                    $parent->addChild($branchName(string) $value);
                }
            } else {
                

    public function __construct($xml$section = null, $options = false)
    {
        if (empty($xml)) {
            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 callback for decoding YAML * * @param callable $yamlDecoder the decoder to set * @return Zend_Config_Yaml */
    public function setYamlDecoder($yamlDecoder)
    {
        if (!is_callable($yamlDecoder)) {
            throw new Zend_Config_Exception('Invalid parameter to setYamlDecoder() - must be callable');
        }

        $this->_yamlDecoder = $yamlDecoder;
        return $this;
    }

    /** * Loads the section $section from the config file encoded as YAML * * 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". * * Options may include: * - allow_modifications: whether or not the config object is mutable * - skip_extends: whether or not to skip processing of parent configuration * - yaml_decoder: a callback to use to decode the Yaml source * * @param string $yaml YAML file to process * @param mixed $section Section to process * @param array|boolean $options */
public function __set($name$value)
    {
        if ($this->_allowModifications) {
            if (is_array($value)) {
                $this->_data[$name] = new self($value, true);
            } else {
                $this->_data[$name] = $value;
            }
            $this->_count = count($this->_data);
        } else {
            /** @see Zend_Config_Exception */
            throw new Zend_Config_Exception('Zend_Config is read only');
        }
    }

    /** * Deep clone of this instance to ensure that nested Zend_Configs * are also cloned. * * @return void */
    public function __clone()
    {
      

    public function __construct($filename$section = null, $options = false)
    {
        if (empty($filename)) {
            /** * @see Zend_Config_Exception */
            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['nestSeparator'])) {
                $this->_nestSeparator = (string) $options['nestSeparator'];
            }


    /** * Set callback for decoding YAML * * @param callable $yamlEncoder the decoder to set * @return Zend_Config_Yaml */
    public function setYamlEncoder($yamlEncoder)
    {
        if (!is_callable($yamlEncoder)) {
            throw new Zend_Config_Exception('Invalid parameter to setYamlEncoder - must be callable');
        }

        $this->_yamlEncoder = $yamlEncoder;
        return $this;
    }

    /** * Render a Zend_Config into a YAML config string. * * @since 1.10 * @return string */

    protected function _prepareValue($value)
    {
        if (is_integer($value) || is_float($value)) {
            return $value;
        } elseif (is_bool($value)) {
            return ($value ? 'true' : 'false');
        } elseif (strpos($value, '"') === false) {
            return '"' . $value .  '"';
        } else {
            /** @see Zend_Config_Exception */
            throw new Zend_Config_Exception('Value can not contain double quotes "');
        }
    }

    /** * Root elements that are not assigned to any section needs to be * on the top of config. * * @see http://framework.zend.com/issues/browse/ZF-6289 * @param Zend_Config * @return Zend_Config */
    


        if ($config !== null) {
            $this->setConfig($config);
        }

        if ($exclusiveLock !== null) {
            $this->setExclusiveLock($exclusiveLock);
        }

        if ($this->_filename === null) {
            throw new Zend_Config_Exception('No filename was set');
        }

        if ($this->_config === null) {
            throw new Zend_Config_Exception('No config was set');
        }

        $configString = $this->render();

        $flags = 0;

        if ($this->_exclusiveLock) {
            

    public function __construct($json$section = null, $options = false)
    {
        if (empty($json)) {
            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;
                        
Home | Imprint | This part of the site doesn't use cookies.