You are here

public function AvatarKitEntityField::submitConfigurationForm in Avatar Kit 8.2

Form submission handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides AvatarKitServiceBase::submitConfigurationForm

File

src/Plugin/Avatars/Service/AvatarKitEntityField.php, line 140

Class

AvatarKitEntityField
Gets avatar from a field in the same entity.

Namespace

Drupal\avatars\Plugin\Avatars\Service

Code

public function submitConfigurationForm(array &$form, FormStateInterface $form_state) : void {
  parent::submitConfigurationForm($form, $form_state);
  $field = $form_state
    ->getValue('field');
  [
    $entity_type,
    $bundle,
    $fieldName,
  ] = explode(':', $field);
  $field_config_id = $entity_type . '.' . $bundle . '.' . $fieldName;
  $fieldConfig = FieldConfig::load($field_config_id);
  if ($fieldConfig) {

    // @todo currently does not work with base fields.
    $this->configuration['field'] = $field_config_id;
  }
}