You are here

protected function ComponentBlock::getCurrentConfiguration in Component blocks 1.1.x

Same name and namespace in other branches
  1. 1.x src/Plugin/Block/ComponentBlock.php \Drupal\component_blocks\Plugin\Block\ComponentBlock::getCurrentConfiguration()
  2. 1.0.x src/Plugin/Block/ComponentBlock.php \Drupal\component_blocks\Plugin\Block\ComponentBlock::getCurrentConfiguration()

Gets the current configuration for given parents.

Parameters

array $parents: The #parents of the element representing the formatter.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array|null The current configuration.

1 call to ComponentBlock::getCurrentConfiguration()
ComponentBlock::formatterSettingsProcessCallback in src/Plugin/Block/ComponentBlock.php
Render API callback: builds the formatter settings elements.

File

src/Plugin/Block/ComponentBlock.php, line 418

Class

ComponentBlock
Defines a class for a specially shaped block.

Namespace

Drupal\component_blocks\Plugin\Block

Code

protected function getCurrentConfiguration(array $parents, FormStateInterface $form_state) : ?array {

  // Use the processed values, if available.
  $configuration = NestedArray::getValue($form_state
    ->getValues(), $parents);
  $variable = end($parents);
  if (!$configuration) {

    // Next check the raw user input.
    $configuration = NestedArray::getValue($form_state
      ->getUserInput(), $parents);
    if (!$configuration) {

      // If no user input exists, use the default values.
      $settings = $this
        ->getConfiguration()['variables'][$variable];
      return $settings;
    }
  }
  return $configuration;
}