PHP Class Jarves\Configuration\Model

Inheritance: implements ArrayAccess
显示文件 Open project: jarves/jarves Class Usage Examples

Public Properties

Property Type Description
$serialisationJarvesCore Jarves\Jarves

Protected Properties

Property Type Description
$_defaultProperties
$_excludeFromExport array
$_modelProperties
$additionalAttributes array Contains the additional (not defined properties) attributes.
$additionalNodes array Contains the additional (not defined properties) children nodes.
$arrayIndexNames array Scenario: ConfigClass => protected $modules; //@var array protected $arrayIndexNames = ['modules' => 'module']; Resulted xml: value value2 If you not defined $arrayIndexNames and if you don't have a proper class name as @var then it will export '' children instead of the ''.
$arrayKey ConfigCacheClass[] Scenario: ConfigClass => protected $caches; //@var ConfigCacheClass[] ConfigCacheClass => protected $id; protected $value; protected $arrayKey => 'id'; ConfigClass->propertyToArray('caches') -> array('' => $ConfigCacheClass, ...)
$attributes array Defines which values are attributes of the element.
$docBlock string Defines a comment for the root element.
$docBlocks array Example: ['caches' => 'blabla']
$element DOMElement The element passed in constructor.
$elementToArray ConfigCacheClass[] Scenario: foo bar Example: ConfigClass => protected $elementToArray = ['cache' => 'caches']; protected $caches; //@var ConfigCacheClass[]
$excludeDefaults array Defines which properties should be excluded when they have the default value.
$jarves Jarves\Jarves
$lastRootElementComment
$nodeValueVar string Defines which property is used as the nodeValue.
$requiredProperties string[] A list of property names that are required and can no be ommited or be null.
$rootName string The name of the element of this class.

Public Methods

Method Description
__construct ( DOMElement | array | string $values = null, Jarves $jarves = null )
__sleep ( )
__toString ( ) : string
__wakeup ( ) }
appendXml ( DOMNode $node, boolean $printDefaults = false, boolean $printComments = false ) : DOMElement Appends the xml structure with our values.
appendXmlProperty ( string $key, DOMNode $parentNode, boolean $printDefaults = false, boolean $printComments = false ) : DOMNode | void
appendXmlValue ( string $key, mixed $value, DOMNode $node, boolean $arrayType = false, boolean $printDefaults = false, boolean $printComments = false ) : DOMNode Appends the xm structure with the given values.
bool ( mixed $val ) : boolean
canPropertyBeExported ( $key )
extractExtraNodes ( DOMNode $child, array &$options )
fromArray ( mixed $values, string $arrayKeyValue = null )
getAdditional ( string $key ) : mixed
getAdditionalAttribute ( string $key ) : mixed
getArrayKey ( )
getArrayKeyValue ( )
getClass ( ) : string
getDirectChild ( string $tag ) : DOMElement
getDirectChildren ( string $tag ) : DOMElement[]
getDocBlock ( ) : string
getDocBlocks ( ) : array
getElement ( ) : DOMElement
getElementArrayName ( $property )
getJarves ( ) : Jarves
getMethodMetaData ( ReflectionMethod | ReflectionClass $reflection ) : array | boolean
getNamespacePath ( )
getParameterValues ( string $element = 'parameters', string $childrenElement = 'parameter', string $keyName = 'id' ) : array first second bar sa
getPropertyDescription ( string $property ) : null | string
getRootName ( ) : string
importNode ( DOMNode $element ) : array
initialize ( $values = null, $jarves = null )
offsetExists ( mixed $offset ) : boolean
offsetGet ( mixed $offset ) : mixed
offsetSet ( mixed $offset, mixed $value )
offsetUnset ( mixed $offset )
parsePhpDoc ( string $string ) : array Parse phpDoc string and returns an array.
propertyFromArray ( string $key, mixed $value )
propertyToArray ( string $k, $printDefaults = false ) : mixed
save ( string $path, boolean $withDefaults = false ) : boolean Saves the xml into a file.
setArrayKeyValue ( $value )
setAttributeVar ( string $variableName )
setElement ( DOMElement $element )
setJarves ( Jarves $jarves )
setVar ( string $variableName )
setupObject ( $jarves = null ) Initialize the object.
toArray ( boolean $printDefaults = false ) : array
toXml ( boolean $printDefaults = false, boolean $printComments = false ) : string Generates a XML string with all current values.

Protected Methods

Method Description
checkRequirements ( ) Checks $this->requiredProperties and throws a exception when not met

Method Details

__construct() public method

public __construct ( DOMElement | array | string $values = null, Jarves $jarves = null )
$values DOMElement | array | string
$jarves Jarves\Jarves

__sleep() public method

public __sleep ( )

__toString() public method

public __toString ( ) : string
return string

__wakeup() public method

}
public __wakeup ( )

appendXml() public method

Appends the xml structure with our values.
public appendXml ( DOMNode $node, boolean $printDefaults = false, boolean $printComments = false ) : DOMElement
$node DOMNode
$printDefaults boolean
$printComments boolean
return DOMElement

appendXmlProperty() public method

public appendXmlProperty ( string $key, DOMNode $parentNode, boolean $printDefaults = false, boolean $printComments = false ) : DOMNode | void
$key string
$parentNode DOMNode
$printDefaults boolean
$printComments boolean
return DOMNode | void

appendXmlValue() public method

Appends the xm structure with the given values.
public appendXmlValue ( string $key, mixed $value, DOMNode $node, boolean $arrayType = false, boolean $printDefaults = false, boolean $printComments = false ) : DOMNode
$key string
$value mixed
$node DOMNode
$arrayType boolean
$printDefaults boolean
$printComments boolean
return DOMNode

bool() public method

public bool ( mixed $val ) : boolean
$val mixed
return boolean

canPropertyBeExported() public method

public canPropertyBeExported ( $key )

checkRequirements() protected method

Checks $this->requiredProperties and throws a exception when not met
protected checkRequirements ( )

extractExtraNodes() public method

public extractExtraNodes ( DOMNode $child, array &$options )
$child DOMNode
$options array

fromArray() public method

public fromArray ( mixed $values, string $arrayKeyValue = null )
$values mixed
$arrayKeyValue string

getAdditional() public method

public getAdditional ( string $key ) : mixed
$key string
return mixed

getAdditionalAttribute() public method

public getAdditionalAttribute ( string $key ) : mixed
$key string
return mixed

getArrayKey() public method

public getArrayKey ( )

getArrayKeyValue() public method

public getArrayKeyValue ( )

getClass() public method

public getClass ( ) : string
return string

getDirectChild() public method

public getDirectChild ( string $tag ) : DOMElement
$tag string
return DOMElement

getDirectChildren() public method

public getDirectChildren ( string $tag ) : DOMElement[]
$tag string
return DOMElement[]

getDocBlock() public method

public getDocBlock ( ) : string
return string

getDocBlocks() public method

public getDocBlocks ( ) : array
return array

getElement() public method

public getElement ( ) : DOMElement
return DOMElement

getElementArrayName() public method

public getElementArrayName ( $property )

getJarves() public method

public getJarves ( ) : Jarves
return Jarves\Jarves

getMethodMetaData() public method

public getMethodMetaData ( ReflectionMethod | ReflectionClass $reflection ) : array | boolean
$reflection ReflectionMethod | ReflectionClass
return array | boolean

getNamespacePath() public method

public getNamespacePath ( )

getParameterValues() public method

=> array( 0 => 'first', 1 => 'second', 'foo' => 'bar', 'ho' => 'sa', )
public getParameterValues ( string $element = 'parameters', string $childrenElement = 'parameter', string $keyName = 'id' ) : array
$element string
$childrenElement string
$keyName string
return array

getPropertyDescription() public method

public getPropertyDescription ( string $property ) : null | string
$property string
return null | string

getRootName() public method

public getRootName ( ) : string
return string

importNode() public method

public importNode ( DOMNode $element ) : array
$element DOMNode
return array imported properties

initialize() public method

public initialize ( $values = null, $jarves = null )

offsetExists() public method

public offsetExists ( mixed $offset ) : boolean
$offset mixed
return boolean

offsetGet() public method

public offsetGet ( mixed $offset ) : mixed
$offset mixed
return mixed

offsetSet() public method

public offsetSet ( mixed $offset, mixed $value )
$offset mixed
$value mixed

offsetUnset() public method

public offsetUnset ( mixed $offset )
$offset mixed

parsePhpDoc() public method

Parse phpDoc string and returns an array.
public parsePhpDoc ( string $string ) : array
$string string
return array

propertyFromArray() public method

public propertyFromArray ( string $key, mixed $value )
$key string
$value mixed

propertyToArray() public method

public propertyToArray ( string $k, $printDefaults = false ) : mixed
$k string name of the property
$printDefaults
return mixed

save() public method

Saves the xml into a file.
public save ( string $path, boolean $withDefaults = false ) : boolean
$path string
$withDefaults boolean
return boolean

setArrayKeyValue() public method

public setArrayKeyValue ( $value )

setAttributeVar() public method

public setAttributeVar ( string $variableName )
$variableName string

setElement() public method

public setElement ( DOMElement $element )
$element DOMElement

setJarves() public method

public setJarves ( Jarves $jarves )
$jarves Jarves\Jarves

setVar() public method

public setVar ( string $variableName )
$variableName string

setupObject() public method

Initialize the object.
public setupObject ( $jarves = null )

toArray() public method

public toArray ( boolean $printDefaults = false ) : array
$printDefaults boolean
return array

toXml() public method

Generates a XML string with all current values.
public toXml ( boolean $printDefaults = false, boolean $printComments = false ) : string
$printDefaults boolean
$printComments boolean
return string

Property Details

$_defaultProperties protected_oe property

protected $_defaultProperties

$_excludeFromExport protected_oe property

protected array $_excludeFromExport
return array

$_modelProperties protected_oe property

protected $_modelProperties

$additionalAttributes protected_oe property

Contains the additional (not defined properties) attributes.
protected array $additionalAttributes
return array

$additionalNodes protected_oe property

Contains the additional (not defined properties) children nodes.
protected array $additionalNodes
return array

$arrayIndexNames protected_oe property

Scenario: ConfigClass => protected $modules; //@var array protected $arrayIndexNames = ['modules' => 'module']; Resulted xml: value value2 If you not defined $arrayIndexNames and if you don't have a proper class name as @var then it will export '' children instead of the ''.
protected array $arrayIndexNames
return array

$arrayKey protected_oe property

Scenario: ConfigClass => protected $caches; //@var ConfigCacheClass[] ConfigCacheClass => protected $id; protected $value; protected $arrayKey => 'id'; ConfigClass->propertyToArray('caches') -> array('' => $ConfigCacheClass, ...)
protected ConfigCacheClass[] $arrayKey
return ConfigCacheClass[]

$attributes protected_oe property

Defines which values are attributes of the element.
protected array $attributes
return array

$docBlock protected_oe property

Defines a comment for the root element.
protected string $docBlock
return string

$docBlocks protected_oe property

Example: ['caches' => 'blabla']
protected array $docBlocks
return array

$element protected_oe property

The element passed in constructor.
protected DOMElement $element
return DOMElement

$elementToArray protected_oe property

Scenario: foo bar Example: ConfigClass => protected $elementToArray = ['cache' => 'caches']; protected $caches; //@var ConfigCacheClass[]
protected ConfigCacheClass[] $elementToArray
return ConfigCacheClass[]

$excludeDefaults protected_oe property

Defines which properties should be excluded when they have the default value.
protected array $excludeDefaults
return array

$jarves protected_oe property

protected Jarves,Jarves $jarves
return Jarves\Jarves

$lastRootElementComment protected_oe property

protected $lastRootElementComment

$nodeValueVar protected_oe property

Defines which property is used as the nodeValue.
protected string $nodeValueVar
return string

$requiredProperties protected_oe property

A list of property names that are required and can no be ommited or be null.
protected string[] $requiredProperties
return string[]

$rootName protected_oe property

The name of the element of this class.
protected string $rootName
return string

$serialisationJarvesCore public_oe static_oe property

public static Jarves,Jarves $serialisationJarvesCore
return Jarves\Jarves