You are here

protected function Pattern::getCurrentField in UI Patterns 8

Get name of field currently being edited.

Return value

string Name of field currently being edited.

1 call to Pattern::getCurrentField()
Pattern::getContext in modules/ui_patterns_ds/src/Plugin/DsFieldTemplate/Pattern.php
Get source field plugin context.

File

modules/ui_patterns_ds/src/Plugin/DsFieldTemplate/Pattern.php, line 157

Class

Pattern
Plugin for the expert field template.

Namespace

Drupal\ui_patterns_ds\Plugin\DsFieldTemplate

Code

protected function getCurrentField() {
  $fields = array_filter($this->parameters
    ->get('fields', []), function ($field) {
    return isset($field['settings_edit_form']['third_party_settings']['ds']['ft']['id']) && $field['settings_edit_form']['third_party_settings']['ds']['ft']['id'] == 'pattern';
  });
  $fields = array_keys($fields);
  $field = reset($fields);
  if (empty($field)) {
    $trigger_element = $this->parameters
      ->get('_triggering_element_name');
    $field = str_replace('_plugin_settings_edit', '', $trigger_element);
  }
  return $field;
}