Zend Framework  2.4
Public Member Functions | Protected Attributes | List of all members
Element Class Reference

Public Member Functions

 __construct ($name=null, $options=array())
 
 init ()
 This function is automatically called when creating element with factory.
 
 setName ($name)
 Set value for name.
 
 getName ()
 Get value for name.
 
 setOptions ($options)
 Set options for an element.
 
 getOptions ()
 Get defined options.
 
 getOption ($option)
 Return the specified option.
 
 setOption ($key, $value)
 Set a single option for an element.
 
 setAttribute ($key, $value)
 Set a single element attribute.
 
 getAttribute ($key)
 Retrieve a single element attribute.
 
 removeAttribute ($key)
 Remove a single attribute.
 
 hasAttribute ($key)
 Does the element has a specific attribute ?
 
 setAttributes ($arrayOrTraversable)
 Set many attributes at once.
 
 getAttributes ()
 Retrieve all attributes at once.
 
 removeAttributes (array $keys)
 Remove many attributes at once.
 
 clearAttributes ()
 Clear all attributes.
 
 setValue ($value)
 Set the element value.
 
 getValue ()
 Retrieve the element value.
 
 setLabel ($label)
 Set the label used for this element.
 
 getLabel ()
 Retrieve the label used for this element.
 
 setLabelAttributes (array $labelAttributes)
 Set the attributes to use with the label.
 
 getLabelAttributes ()
 Get the attributes to use with the label.
 
 setLabelOptions ($arrayOrTraversable)
 Set many label options at once.
 
 getLabelOptions ()
 Get label specific options.
 
 clearLabelOptions ()
 Clear all label options.
 
 removeLabelOptions (array $keys)
 Remove many attributes at once.
 
 setLabelOption ($key, $value)
 Set a single label optionn.
 
 getLabelOption ($key)
 Retrieve a single label option.
 
 removeLabelOption ($key)
 Remove a single label option.
 
 hasLabelOption ($key)
 Does the element has a specific label option ?
 
 setMessages ($messages)
 Set a list of messages to report when validation fails.
 
 getMessages ()
 Get validation error messages, if any.
 

Protected Attributes

 $attributes = array()
 
 $label
 
 $labelAttributes = array()
 
 $labelOptions = array()
 
 $messages = array()
 
 $options = array()
 
 $value
 

Constructor & Destructor Documentation

__construct (   $name = null,
  $options = array() 
)
Parameters
null | int | string$nameOptional name for the element
array$optionsOptional options for the element
Exceptions
Exception\InvalidArgumentException

Member Function Documentation

clearAttributes ( )

Clear all attributes.

Returns
Element|ElementInterface

Implements ElementAttributeRemovalInterface.

clearLabelOptions ( )

Clear all label options.

Returns
Element|ElementInterface

Implements LabelAwareInterface.

getAttribute (   $key)

Retrieve a single element attribute.

Parameters
$key
Returns
mixed|null

Implements ElementInterface.

getAttributes ( )

Retrieve all attributes at once.

Returns
array|Traversable

Implements ElementInterface.

getLabel ( )

Retrieve the label used for this element.

Returns
null|string

Implements ElementInterface.

getLabelAttributes ( )

Get the attributes to use with the label.

Returns
array

Implements LabelAwareInterface.

getLabelOption (   $key)

Retrieve a single label option.

Parameters
$key
Returns
mixed|null

Implements LabelAwareInterface.

getLabelOptions ( )

Get label specific options.

Returns
array

Implements LabelAwareInterface.

getMessages ( )

Get validation error messages, if any.

Returns a list of validation failure messages, if any.

Returns
array|Traversable

Implements ElementInterface.

getName ( )

Get value for name.

Returns
string|int

Implements ElementInterface.

getOption (   $option)

Return the specified option.

Parameters
string$option
Returns
NULL|mixed

Implements ElementInterface.

getOptions ( )

Get defined options.

Returns
array

Implements ElementInterface.

getValue ( )

Retrieve the element value.

Returns
mixed

Implements ElementInterface.

hasAttribute (   $key)

Does the element has a specific attribute ?

Parameters
string$key
Returns
bool

Implements ElementInterface.

hasLabelOption (   $key)

Does the element has a specific label option ?

Parameters
string$key
Returns
bool

Implements LabelAwareInterface.

init ( )

This function is automatically called when creating element with factory.

It allows to perform various operations (add elements...)

Returns
void

Implements InitializableInterface.

removeAttribute (   $key)

Remove a single attribute.

Parameters
string$key
Returns
ElementInterface

Implements ElementAttributeRemovalInterface.

removeAttributes ( array  $keys)

Remove many attributes at once.

Parameters
array$keys
Returns
ElementInterface

Implements ElementAttributeRemovalInterface.

removeLabelOption (   $key)

Remove a single label option.

Parameters
string$key
Returns
ElementInterface

Implements LabelAwareInterface.

removeLabelOptions ( array  $keys)

Remove many attributes at once.

Parameters
array$keys
Returns
ElementInterface

Implements LabelAwareInterface.

setAttribute (   $key,
  $value 
)

Set a single element attribute.

Parameters
string$key
mixed$value
Returns
Element|ElementInterface

Implements ElementInterface.

setAttributes (   $arrayOrTraversable)

Set many attributes at once.

Implementation will decide if this will overwrite or merge.

Parameters
array | Traversable$arrayOrTraversable
Returns
Element|ElementInterface
Exceptions
Exception\InvalidArgumentException

Implements ElementInterface.

setLabel (   $label)

Set the label used for this element.

Parameters
$label
Returns
Element|ElementInterface

Implements ElementInterface.

setLabelAttributes ( array  $labelAttributes)

Set the attributes to use with the label.

Parameters
array$labelAttributes
Returns
Element|ElementInterface

Implements LabelAwareInterface.

setLabelOption (   $key,
  $value 
)

Set a single label optionn.

Parameters
string$key
mixed$value
Returns
Element|ElementInterface

Implements LabelAwareInterface.

setLabelOptions (   $arrayOrTraversable)

Set many label options at once.

Implementation will decide if this will overwrite or merge.

Parameters
array | Traversable$arrayOrTraversable
Returns
Element|ElementInterface
Exceptions
Exception\InvalidArgumentException

Implements LabelAwareInterface.

setMessages (   $messages)

Set a list of messages to report when validation fails.

Parameters
array | Traversable$messages
Returns
Element|ElementInterface
Exceptions
Exception\InvalidArgumentException

Implements ElementInterface.

setName (   $name)

Set value for name.

Parameters
string$name
Returns
Element|ElementInterface

Implements ElementInterface.

setOption (   $key,
  $value 
)

Set a single option for an element.

Parameters
string$key
mixed$value
Returns
self

Implements ElementInterface.

setOptions (   $options)

Set options for an element.

Accepted options are:

  • label: label to associate with the element
  • label_attributes: attributes to use when the label is rendered
  • label_options: label specific options
Parameters
array | Traversable$options
Returns
Element|ElementInterface
Exceptions
Exception\InvalidArgumentException

Implements ElementInterface.

setValue (   $value)

Set the element value.

Parameters
mixed$value
Returns
Element

Implements ElementInterface.

Member Data Documentation

$attributes = array()
protected
$label
protected
$labelAttributes = array()
protected
$labelOptions = array()
protected
$messages = array()
protected
$options = array()
protected
$value
protected