protected function FieldWidgetComponentType::getFieldDefinitions in Flexiform 8
Get the field definitions.
2 calls to FieldWidgetComponentType::getFieldDefinitions()
- FieldWidgetComponentType::componentRows in src/
Plugin/ FormComponentType/ FieldWidgetComponentType.php - FieldWidgetComponentType::getFieldDefinition in src/
Plugin/ FormComponentType/ FieldWidgetComponentType.php - Get a field definition.
File
- src/
Plugin/ FormComponentType/ FieldWidgetComponentType.php, line 96
Class
- FieldWidgetComponentType
- Plugin for field widget component types.
Namespace
Drupal\flexiform\Plugin\FormComponentTypeCode
protected function getFieldDefinitions() {
if (empty($this->fieldDefinitions)) {
foreach ($this
->getFormEntityManager()
->getFormEntities() as $namespace => $form_entity) {
foreach ($this->entityFieldManager
->getFieldDefinitions($form_entity
->getEntityType(), $form_entity
->getBundle()) as $field_name => $field_definition) {
if ($this
->getFormDisplay()
->getMode() === EntityDisplayBase::CUSTOM_MODE || $field_definition
->getDisplayOptions('form')) {
// Give field definitions a clone for form entities so that
// overrides don't copy accross two different fields.
$component_name = !empty($namespace) ? "{$namespace}:{$field_name}" : $field_name;
$this->fieldDefinitions[$component_name] = clone $field_definition;
// Apply overrides.
$component_options = $this
->getFormDisplay()
->getComponent($component_name);
if (!empty($component_options['third_party_settings']['flexiform']['field_definition'])) {
$def_overrides = $component_options['third_party_settings']['flexiform']['field_definition'];
if (!empty($def_overrides['label'])) {
$this->fieldDefinitions[$component_name]
->setLabel($def_overrides['label']);
}
if (!empty($def_overrides['settings'])) {
$settings = $this->fieldDefinitions[$component_name]
->getSettings();
$settings = NestedArray::mergeDeep($settings, $def_overrides['settings']);
$this->fieldDefinitions[$component_name]
->setSettings($settings);
}
}
}
}
}
}
return $this->fieldDefinitions;
}