Class: I2CE FormFactory

From IHRIS Wiki
Revision as of 20:20, 16 October 2009 by Litlfred (talk | contribs)

This article desrcibes the class I2CE_FormFactory which extends the class I2CE_Fuzzy It is contained in the module forms in the package I2CE

The class is defined in the file: modules/Forms/lib/I2CE_FormFactory.php

@author Luke Duncan <lduncan@intrahealth.org>

@since v1.0.0

@version v2.0.0

This factory is used to create instances of I2CE_Form objects from the form name.

@package I2CE

@access public

Variables

$instance

The single instance of this class.

$classes

The classes that have been registered with the factory.

  • Type: private y $classes

Methods

__construct()

  • Signature: public function __construct()

callStatic()

Call a static function in the form's class object.

  • Signature: public function callStatic($form,$func,$args)

Parameters:

  • string $form
    The name of the form.
  • string $func
    The function to be called.
  • array $args
    The arguments to pass to the function.
    • Default Value: array()

createForm()

Return an instance of a I2CE_Form from the factory.

  • Signature: public function createForm($formId)
  • Returns: I2CE_Form or null on failure

Parameters:

  • string $formId
    The name of the form possible with an id

exists()

Checks to see if the given form has been registered.

  • Signature: public function exists($form)
  • Returns: boolean

Parameters:

  • string $form
    The name of the form.

getClassHierarchy()

Get the class hierarchy associated to a class.

  • Signature: public function getClassHierarchy($form)
  • Returns: array The keys of the array range from 0 to N. The value of key 0 is the class associated to the form. The last key is has value 'I2CE_Form'.

Returns null in error. Parameters:

  • $form

getClassName()

  • Signature: public function getClassName($form)

Parameters:

  • $form

getConst()

Shortcut to retrieving a constant value from a form's class object.

  • Signature: public function getConst($form,$var)

Parameters:

  • string $form
    The name of the form.
  • string $var
    The name of the constant.

getFieldNames()

Get the fields for a given form via what is stored in magic data. @param mixed $restict. Defaults to null which means there are no restrictions. Otherwise it should be an array consisting of any numbder of the following keys 'in_db', 'required', and 'unique' the values associated to each key should be true or false. We then only return fields who match the given value

  • Signature: public function getFieldNames($form,$restrictions)
  • Returns: associative array of string. key is the field the value is the form class

Parameters:

  • string $form
    the short name of a form
  • $restrictions
    • Default Value: array()

getForms()

get the available forms.

  • Signature: public function getForms()
  • Returns: array with values the form name

getStatic()

Return a static variable from the form's class object.

  • Signature: public function getStatic($form,$var,$const)

Parameters:

  • string $form
    The name of the form.
  • string $var
    The name of the variable.
  • boolean $const
    Set to true to get a constant instead of a variable
    • Default Value: false

instance()

Return the instance of this factory and create it if it doesn't exist.

  • Signature: static public function instance()

Inherited Fuzzy Methods

userMessage()

This method is inherited from I2CE_Fuzzy->userMessage()

Fuzzy Methods

getRecords()

This method is implemented by I2CE_FormStorage->getRecords()