public static function WebformFieldsUnchangedDataDefinition::create in RULES WEBFORM 3.x
Same name and namespace in other branches
- 8 src/WebformFieldsUnchangedDataDefinition.php \Drupal\rules_webform\WebformFieldsUnchangedDataDefinition::create()
Creates a new 'webform_field_unchanged' definition.
Parameters
string $type: (optional) The data type of the map. Defaults to 'webform_field'.
Return value
static
Overrides MapDataDefinition::create
File
- src/
WebformFieldsUnchangedDataDefinition.php, line 22
Class
- WebformFieldsUnchangedDataDefinition
- A typed data definition class for defining 'webform_fields_unchanged'.
Namespace
Drupal\rules_webformCode
public static function create($type = 'webform_fields_unchanged') {
$definition['type'] = $type;
$webform_fields_definition = new static($definition);
// Array of a webform fields names and titles which has
// the following structure:
// ['field 1 name' => 'field 1 title', 'field 2 name' => 'field 2 title'].
$fieldsDefinitions = \Drupal::state()
->get('rules_webform.fields_definitions');
foreach ($fieldsDefinitions as $name => $title) {
$property_definition = \Drupal::typedDataManager()
->createDataDefinition('string');
$property_definition
->setLabel($title);
$webform_fields_definition
->setPropertyDefinition($name, $property_definition);
}
return $webform_fields_definition;
}