Zend Framework  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Factory Class Reference

Public Member Functions

 __construct (FormElementManager $formElementManager=null)
 
 setInputFilterFactory (InputFilterFactory $inputFilterFactory)
 Set input filter factory to use when creating forms.
 
 getInputFilterFactory ()
 Get current input filter factory.
 
 setFormElementManager (FormElementManager $formElementManager)
 Set the form element manager.
 
 getFormElementManager ()
 Get form element manager.
 
 create ($spec)
 Create an element, fieldset, or form.
 
 createElement ($spec)
 Create an element.
 
 createFieldset ($spec)
 Create a fieldset.
 
 createForm ($spec)
 Create a form.
 
 configureElement (ElementInterface $element, $spec)
 Configure an element based on the provided specification.
 
 configureFieldset (FieldsetInterface $fieldset, $spec)
 Configure a fieldset based on the provided specification.
 
 configureForm (FormInterface $form, $spec)
 Configure a form based on the provided specification.
 
 prepareAndInjectFieldsets ($fieldsets, FieldsetInterface $masterFieldset, $method)
 Takes a list of fieldset specifications, creates the fieldsets, and injects them into the master fieldset.
 

Protected Member Functions

 validateSpecification ($spec, $method)
 Validate a provided specification.
 
 prepareAndInjectElements ($elements, FieldsetInterface $fieldset, $method)
 Takes a list of element specifications, creates the elements, and injects them into the provided fieldset.
 
 prepareAndInjectObject ($objectName, FieldsetInterface $fieldset, $method)
 Prepare and inject an object.
 
 prepareAndInjectHydrator ($hydratorOrName, FieldsetInterface $fieldset, $method)
 Prepare and inject a named hydrator.
 
 prepareAndInjectFactory ($factoryOrName, FieldsetInterface $fieldset, $method)
 Prepare and inject a named factory.
 
 prepareAndInjectInputFilter ($spec, FormInterface $form, $method)
 Prepare an input filter instance and inject in the provided form.
 
 prepareAndInjectValidationGroup ($spec, FormInterface $form, $method)
 Prepare a validation group and inject in the provided form.
 
 getHydratorFromName ($hydratorName)
 Try to pull hydrator from service manager, or instantiates it from its name.
 
 getFactoryFromName ($factoryName)
 Try to pull factory from service manager, or instantiates it from its name.
 

Protected Attributes

 $inputFilterFactory
 
 $formElementManager
 

Constructor & Destructor Documentation

__construct ( FormElementManager  $formElementManager = null)
Parameters
FormElementManager$formElementManager

Member Function Documentation

configureElement ( ElementInterface  $element,
  $spec 
)

Configure an element based on the provided specification.

Specification can contain any of the following:

  • type: the Element class to use; defaults to
  • name: what name to provide the element, if any
  • options: an array, Traversable, or ArrayAccess object of element options
  • attributes: an array, Traversable, or ArrayAccess object of element attributes to assign
Parameters
ElementInterface$element
array | Traversable | ArrayAccess$spec
Exceptions
Exception\DomainException
Returns
ElementInterface
configureFieldset ( FieldsetInterface  $fieldset,
  $spec 
)

Configure a fieldset based on the provided specification.

Specification can contain any of the following:

  • type: the Fieldset class to use; defaults to
  • name: what name to provide the fieldset, if any
  • options: an array, Traversable, or ArrayAccess object of element options
  • attributes: an array, Traversable, or ArrayAccess object of element attributes to assign
  • elements: an array or Traversable object where each entry is an array or ArrayAccess object containing the keys:
Parameters
FieldsetInterface$fieldset
array | Traversable | ArrayAccess$spec
Exceptions
Exception\DomainException
Returns
FieldsetInterface
configureForm ( FormInterface  $form,
  $spec 
)

Configure a form based on the provided specification.

Specification follows that of configureFieldset(), and adds the following keys:

  • input_filter: input filter instance, named input filter class, or array specification for the input filter factory
  • hydrator: hydrator instance or named hydrator class
Parameters
FormInterface$form
array | Traversable | ArrayAccess$spec
Returns
FormInterface
create (   $spec)

Create an element, fieldset, or form.

Introspects the 'type' key of the provided $spec, and determines what type is being requested; if none is provided, assumes the spec represents simply an element.

Parameters
array | Traversable$spec
Returns
ElementInterface
Exceptions
Exception\DomainException
createElement (   $spec)

Create an element.

Parameters
array$spec
Returns
ElementInterface
createFieldset (   $spec)

Create a fieldset.

Parameters
array$spec
Returns
ElementInterface
createForm (   $spec)

Create a form.

Parameters
array$spec
Returns
ElementInterface
getFactoryFromName (   $factoryName)
protected

Try to pull factory from service manager, or instantiates it from its name.

Parameters
string$factoryName
Returns
mixed
Exceptions
Exception\DomainException
getFormElementManager ( )

Get form element manager.

Returns
FormElementManager
getHydratorFromName (   $hydratorName)
protected

Try to pull hydrator from service manager, or instantiates it from its name.

Parameters
string$hydratorName
Returns
mixed
Exceptions
Exception\DomainException
getInputFilterFactory ( )

Get current input filter factory.

If none provided, uses an unconfigured instance.

Returns
InputFilterFactory
prepareAndInjectElements (   $elements,
FieldsetInterface  $fieldset,
  $method 
)
protected

Takes a list of element specifications, creates the elements, and injects them into the provided fieldset.

Parameters
array | Traversable | ArrayAccess$elements
FieldsetInterface$fieldset
string$methodMethod invoking this one (for exception messages)
Returns
void
prepareAndInjectFactory (   $factoryOrName,
FieldsetInterface  $fieldset,
  $method 
)
protected

Prepare and inject a named factory.

Takes a string indicating a factory class name (or a concrete instance), try first to instantiates the class by pulling it from service manager, and injects the factory instance into the fieldset.

Parameters
string | array | Factory$factoryOrName
FieldsetInterface$fieldset
string$method
Returns
void
Exceptions
Exception\DomainExceptionIf $factoryOrName is not a string, does not resolve to a known class, or the class does not extend Form
prepareAndInjectFieldsets (   $fieldsets,
FieldsetInterface  $masterFieldset,
  $method 
)

Takes a list of fieldset specifications, creates the fieldsets, and injects them into the master fieldset.

Parameters
array | Traversable | ArrayAccess$fieldsets
FieldsetInterface$masterFieldset
string$methodMethod invoking this one (for exception messages)
Returns
void
prepareAndInjectHydrator (   $hydratorOrName,
FieldsetInterface  $fieldset,
  $method 
)
protected

Prepare and inject a named hydrator.

Takes a string indicating a hydrator class name (or a concrete instance), try first to instantiates the class by pulling it from service manager, and injects the hydrator instance into the form.

Parameters
string | array | Hydrator\HydratorInterface$hydratorOrName
FieldsetInterface$fieldset
string$method
Returns
void
Exceptions
Exception\DomainExceptionIf $hydratorOrName is not a string, does not resolve to a known class, or the class does not implement Hydrator
prepareAndInjectInputFilter (   $spec,
FormInterface  $form,
  $method 
)
protected

Prepare an input filter instance and inject in the provided form.

If the input filter specified is a string, assumes it is a class name, and attempts to instantiate it. If the class does not exist, or does not extend InputFilterInterface, an exception is raised.

Otherwise, $spec is passed on to the attached InputFilter Factory instance in order to create the input filter.

Parameters
string | array | Traversable$spec
FormInterface$form
string$method
Returns
void
Exceptions
Exception\DomainExceptionfor unknown InputFilter class or invalid InputFilter instance
prepareAndInjectObject (   $objectName,
FieldsetInterface  $fieldset,
  $method 
)
protected

Prepare and inject an object.

Takes a string indicating a class name, instantiates the class by that name, and injects the class instance as the bound object.

Parameters
string$objectName
FieldsetInterface$fieldset
string$method
Exceptions
Exception\DomainException
Returns
void
prepareAndInjectValidationGroup (   $spec,
FormInterface  $form,
  $method 
)
protected

Prepare a validation group and inject in the provided form.

Takes an array of elements names

Parameters
string | array | Traversable$spec
FormInterface$form
string$method
Returns
void
Exceptions
Exception\DomainExceptionif validation group given is not an array
setFormElementManager ( FormElementManager  $formElementManager)

Set the form element manager.

Parameters
FormElementManager$formElementManager
Returns
Factory
setInputFilterFactory ( InputFilterFactory  $inputFilterFactory)

Set input filter factory to use when creating forms.

Parameters
InputFilterFactory$inputFilterFactory
Returns
Factory
validateSpecification (   $spec,
  $method 
)
protected

Validate a provided specification.

Ensures we have an array, Traversable, or ArrayAccess object, and returns it.

Parameters
array | Traversable | ArrayAccess$spec
string$methodMethod invoking the validator
Returns
array|ArrayAccess
Exceptions
Exception\InvalidArgumentExceptionfor invalid $spec

Member Data Documentation

$formElementManager
protected
$inputFilterFactory
protected