public static function FlexiformElement::createElement in Flexiform 7
Create an element object.
2 calls to FlexiformElement::createElement()
- flexiform_manage_form_fields_form_submit in ./
flexiform.admin.inc - Submit handler for the flexiform_manage_form_fields_form
- flexiform_webform_field_create_instance in flexiform_webform/
flexiform_webform.module - Implements hook_field_create_instance().
File
- includes/
flexiform.element.inc, line 487 - Controller class for flexiform elements.
Class
- FlexiformElement
- Base class for all FlexiformElements
Code
public static function createElement($flexiform, $settings) {
$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';
}
return new $class_name($flexiform, $settings);
}