Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Zend_Config_Yaml Class Reference

Public Member Functions

 getYamlDecoder ()
 Get callback for decoding YAML.
 
 setYamlDecoder ($yamlDecoder)
 Set callback for decoding YAML.
 
 __construct ($yaml, $section=null, $options=false)
 Loads the section $section from the config file encoded as YAML.
 
- Public Member Functions inherited from Zend_Config
 __construct (array $array, $allowModifications=false)
 Zend_Config provides a property based interface to an array.
 
 get ($name, $default=null)
 Retrieve a value and return $default if there is no element set.
 
 __get ($name)
 Magic function so that $obj->value will work.
 
 __set ($name, $value)
 Only allow setting of a property if $allowModifications was set to true on construction.
 
 __clone ()
 Deep clone of this instance to ensure that nested Zend_Configs are also cloned.
 
 toArray ()
 Return an associative array of the stored data.
 
 __isset ($name)
 Support isset() overloading on PHP 5.1.
 
 __unset ($name)
 Support unset() overloading on PHP 5.1.
 
 count ()
 Defined by Countable interface.
 
 current ()
 Defined by Iterator interface.
 
 key ()
 Defined by Iterator interface.
 
 next ()
 Defined by Iterator interface.
 
 rewind ()
 Defined by Iterator interface.
 
 valid ()
 Defined by Iterator interface.
 
 getSectionName ()
 Returns the section name(s) loaded.
 
 areAllSectionsLoaded ()
 Returns true if all sections were loaded.
 
 merge (Zend_Config $merge)
 Merge another Zend_Config with this one.
 
 setReadOnly ()
 Prevent any more modifications being made to this instance.
 
 readOnly ()
 Returns if this Zend_Config object is read only or not.
 
 getExtends ()
 Get the current extends.
 
 setExtend ($extendingSection, $extendedSection=null)
 Set an extend for Zend_Config_Writer.
 
 _loadFileErrorHandler ($errno, $errstr, $errfile, $errline)
 Handle any errors from simplexml_load_file or parse_ini_file.
 

Static Public Member Functions

static setIgnoreConstants ($flag)
 Indicate whether parser should ignore constants or not.
 
static ignoreConstants ()
 Whether parser should ignore constants or not.
 
static decode ($yaml)
 Very dumb YAML parser.
 

Public Attributes

const EXTENDS_NAME = "_extends"
 Attribute name that indicates what section a config extends from.
 

Protected Member Functions

 _processExtends (array $data, $section, array $config=array())
 Helper function to process each element in the section and handle the "_extends" inheritance attribute.
 
- Protected Member Functions inherited from Zend_Config
 _assertValidExtend ($extendingSection, $extendedSection)
 Throws an exception if $extendingSection may not extend $extendedSection, and tracks the section extension if it is valid.
 
 _arrayMergeRecursive ($firstArray, $secondArray)
 Merge two arrays recursively, overwriting keys of the same name in $firstArray with the value in $secondArray.
 

Static Protected Member Functions

static _decodeYaml ($currentIndent, &$lines)
 Service function to decode YAML.
 
static _parseValue ($value)
 Parse values.
 
static _replaceConstants ($value)
 Replace any constants referenced in a string with their values.
 
static _getConstants ()
 Get (reverse) sorted list of defined constant names.
 

Protected Attributes

 $_skipExtends = false
 
 $_yamlDecoder = array(__CLASS__, 'decode')
 
- Protected Attributes inherited from Zend_Config
 $_allowModifications
 
 $_index
 
 $_count
 
 $_data
 
 $_skipNextIteration
 
 $_loadedSection
 
 $_extends = array()
 
 $_loadFileErrorStr = null
 

Static Protected Attributes

static $_ignoreConstants = false
 

Constructor & Destructor Documentation

__construct (   $yaml,
  $section = null,
  $options = false 
)

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
Parameters
string$yamlYAML file to process
mixed$sectionSection to process
array | boolean$options

Member Function Documentation

static _decodeYaml (   $currentIndent,
$lines 
)
staticprotected

Service function to decode YAML.

Parameters
int$currentIndentCurrent indent level
array$linesYAML lines
Returns
array|string
static _getConstants ( )
staticprotected

Get (reverse) sorted list of defined constant names.

Returns
array
static _parseValue (   $value)
staticprotected

Parse values.

Parameters
string$value
Returns
string
_processExtends ( array  $data,
  $section,
array  $config = array() 
)
protected

Helper function to process each element in the section and handle the "_extends" inheritance attribute.

Parameters
array$dataData array to process
string$sectionSection to process
array$configConfiguration which was parsed yet
Returns
array
Exceptions
Zend_Config_ExceptionWhen $section cannot be found
static _replaceConstants (   $value)
staticprotected

Replace any constants referenced in a string with their values.

Parameters
string$value
Returns
string
static decode (   $yaml)
static

Very dumb YAML parser.

Until we have Zend_Yaml...

Parameters
string$yamlYAML source
Returns
array Decoded data
getYamlDecoder ( )

Get callback for decoding YAML.

Returns
callable
static ignoreConstants ( )
static

Whether parser should ignore constants or not.

Returns
bool
static setIgnoreConstants (   $flag)
static

Indicate whether parser should ignore constants or not.

Parameters
bool$flag
Returns
void
setYamlDecoder (   $yamlDecoder)

Set callback for decoding YAML.

Parameters
callable$yamlDecoderthe decoder to set
Returns
Zend_Config_Yaml

Member Data Documentation

$_ignoreConstants = false
staticprotected
$_skipExtends = false
protected
$_yamlDecoder = array(__CLASS__, 'decode')
protected
const EXTENDS_NAME = "_extends"

Attribute name that indicates what section a config extends from.