You are here

protected function ExtraFieldTypePluginBase::getPluginFormStateValue in Entity Extra Field 8

Same name and namespace in other branches
  1. 2.0.x src/ExtraFieldTypePluginBase.php \Drupal\entity_extra_field\ExtraFieldTypePluginBase::getPluginFormStateValue()

Get plugin form state value.

Parameters

string|array $key: The element key.

\Drupal\Core\Form\FormStateInterface $form_state: The form state instance.

null $default: The default value if nothing is found.

Return value

mixed|null The form value; otherwise FALSE if the value can't be found.

3 calls to ExtraFieldTypePluginBase::getPluginFormStateValue()
ExtraFieldBlockPlugin::buildConfigurationForm in src/Plugin/ExtraFieldType/ExtraFieldBlockPlugin.php
Form constructor.
ExtraFieldTokenPlugin::buildConfigurationForm in src/Plugin/ExtraFieldType/ExtraFieldTokenPlugin.php
Form constructor.
ExtraFieldViewsPlugin::buildConfigurationForm in src/Plugin/ExtraFieldType/ExtraFieldViewsPlugin.php
Form constructor.

File

src/ExtraFieldTypePluginBase.php, line 385

Class

ExtraFieldTypePluginBase
Define extra field type plugin base.

Namespace

Drupal\entity_extra_field

Code

protected function getPluginFormStateValue($key, FormStateInterface $form_state, $default = NULL) {
  $key = !is_array($key) ? [
    $key,
  ] : $key;
  $inputs = [
    $form_state
      ->cleanValues()
      ->getValues(),
    $this
      ->getConfiguration(),
  ];
  foreach ($inputs as $input) {
    $value = NestedArray::getValue($input, $key, $key_exists);
    if (!isset($value) && !$key_exists) {
      continue;
    }
    return $value;
  }
  return $default;
}