You are here

public static function FlexiformElement::getElement in Flexiform 7

Get an element object.

14 calls to FlexiformElement::getElement()
FlexiformBuilderFlexiform::form in includes/builder/flexiform.builder.inc
Build the form for this flexiform.
FlexiformFCHandler::calculateElementCompleteness in flexiform_webform/flexiform_webform.fc.inc
Calculate if a given element is complete.
FlexiformFCHandler::elementIgnored in flexiform_webform/flexiform_webform.fc.inc
Calculate whether an element has been ignored.
flexiform_conditional_fields_configure_form in flexiform_conditional_fields/flexiform_conditional_fields.admin.inc
Form to edit conditional fields.
flexiform_conditional_fields_delete_form in flexiform_conditional_fields/flexiform_conditional_fields.admin.inc
Form to delete conditional fields.

... See full list

File

includes/flexiform.element.inc, line 452
Controller class for flexiform elements.

Class

FlexiformElement
Base class for all FlexiformElements

Code

public static function getElement($flexiform, $element_namespace) {
  $cached_elements =& drupal_static(__CLASS__, array());
  if (empty($cached_elements[$flexiform->form][$element_namespace])) {
    $settings = $flexiform->elements[$element_namespace];
    $entity_namespace = $settings['entity_namespace'];
    $element_name = $settings['element_name'];

    // If we don't have a cached version then create one.
    $entity_type = $flexiform->entities[$entity_namespace]['entity_type'];
    $bundle = $flexiform->entities[$entity_namespace]['bundle'];
    $element_info = flexiform_get_element_info($entity_type, $bundle, $element_name);
    $class_name = $element_info['class'];
    if (!class_exists($class_name) || !in_array('FlexiformElementInterface', class_implements($class_name))) {
      watchdog('flexiform', 'Invalid Flexiform Element class !class_name for element !element_name', array(
        '!class_name' => $class_name,
        '!element_name' => $element_name,
      ), WATCHDOG_WARNING);
      $class_name = 'FlexiformElementBroken';
    }
    $cached_elements[$flexiform->form][$element_namespace] = new $class_name($flexiform, $settings, $element_namespace);
  }
  return $cached_elements[$flexiform->form][$element_namespace];
}