Default listeners for element annotations

Defines and attaches a set of default listeners for element annotations (which are defined on object properties). These include:

  • AllowEmpty
  • Attributes
  • ErrorMessage
  • Filter
  • Flags
  • Input
  • Hydrator
  • Object and Instance (the latter is preferred starting in 2.4)
  • Required
  • Type
  • Validator

See the individual annotation classes for more details. The handlers registered work with the annotation values, as well as the element and input specification passed in the event object.

package Default
inherited_from \Zend\Form\Annotation\AbstractAnnotationsListener

 Methods

{@inheritDoc}

attach(\Zend\EventManager\EventManagerInterface $events) 

Parameters

$events

Detach all previously attached listeners

detach(\Zend\EventManager\EventManagerInterface $events) 
Inherited
inherited_from \Zend\EventManager\ListenerAggregateInterface::detach()

Parameters

$events

Discover the fallback name via reflection

discoverFallbackName(\Zend\EventManager\EventInterface $e) : string
Inherited

Parameters

$e

\Zend\EventManager\EventInterface

Returns

string

Handle the AllowEmpty annotation

handleAllowEmptyAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the allow_empty flag on the input specification array.

Parameters

$e

\Zend\EventManager\EventInterface

Handle the Attributes annotation

handleAttributesAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the attributes array of the element specification.

Parameters

$e

\Zend\EventManager\EventInterface

Allow creating fieldsets from composed entity properties

handleComposedObjectAnnotation(\Zend\EventManager\EventInterface $e) : void

Parameters

$e

\Zend\EventManager\EventInterface

Handle the ContinueIfEmpty annotation

handleContinueIfEmptyAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the continue_if_empty flag on the input specification array.

Parameters

$e

\Zend\EventManager\EventInterface

Handle the ErrorMessage annotation

handleErrorMessageAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the error_message of the input specification.

Parameters

$e

\Zend\EventManager\EventInterface

Determine if the element has been marked to exclude from the definition

handleExcludeAnnotation(\Zend\EventManager\EventInterface $e) : boolean

Parameters

$e

\Zend\EventManager\EventInterface

Returns

boolean

Handle the Filter annotation

handleFilterAnnotation(\Zend\EventManager\EventInterface $e) : void

Adds a filter to the filter chain specification for the input.

Parameters

$e

\Zend\EventManager\EventInterface

Handle the Flags annotation

handleFlagsAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the element flags in the specification (used typically for setting priority).

Parameters

$e

\Zend\EventManager\EventInterface

Handle the Hydrator annotation

handleHydratorAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the hydrator class to use in the fieldset specification.

Parameters

$e

\Zend\EventManager\EventInterface

Handle the Input annotation

handleInputAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the filter specification for the current element to the specified input class name.

Parameters

$e

\Zend\EventManager\EventInterface

Attempt to discover a name set via annotation

handleNameAnnotation(\Zend\EventManager\EventInterface $e) : false | string
Inherited

Parameters

$e

\Zend\EventManager\EventInterface

Returns

falsestring

Handle the Object and Instance annotations

handleObjectAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the object to bind to the form or fieldset

Parameters

$e

\Zend\EventManager\EventInterface

Handle the Options annotation

handleOptionsAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the element options in the specification.

Parameters

$e

\Zend\EventManager\EventInterface

Handle the Required annotation

handleRequiredAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the required flag on the input based on the annotation value.

Parameters

$e

\Zend\EventManager\EventInterface

Handle the Type annotation

handleTypeAnnotation(\Zend\EventManager\EventInterface $e) : void

Sets the element class type to use in the element specification.

Parameters

$e

\Zend\EventManager\EventInterface

Handle the Validator annotation

handleValidatorAnnotation(\Zend\EventManager\EventInterface $e) : void

Adds a validator to the validator chain of the input specification.

Parameters

$e

\Zend\EventManager\EventInterface

mergeOptions()

mergeOptions(array|\ArrayAccess $elementSpec, \Zend\Form\Annotation\ComposedObject|\Zend\Form\Annotation\Options $annotation) : array

Parameters

$elementSpec

array\ArrayAccess

$annotation

\Zend\Form\Annotation\ComposedObject\Zend\Form\Annotation\Options

Returns

array

 Properties

 

$listeners

$listeners : array<mixed,\Zend\Stdlib\CallbackHandler>

Default

array()