You are here

public function TwitterTimelineWidget::setDependentConfiguration in Twitter Embed 8

Set the configuration state based on the chosen options.

Some options are dependent to others, resets the options that does not need values or set the default configuration to avoid a configuration state that does not comply with the Twitter widgets.

Parameters

array $configuration: List of selected configuration.

Overrides TwitterWidgetInterface::setDependentConfiguration

File

src/TwitterTimelineWidget.php, line 228

Class

TwitterTimelineWidget
Class TwitterTimelineWidget.

Namespace

Drupal\twitter_embed

Code

public function setDependentConfiguration(array &$configuration) {

  // @todo these rules should be used in form validation.
  // Empty the type_value when unnecessary.
  if (!in_array($configuration['type'], [
    'list',
    'collection',
  ])) {
    $configuration['type_value'] = '';
  }

  // The grid display_style is available for collection type only.
  if ($configuration['type'] !== 'collection') {
    $configuration['display_style'] = 'timeline';
  }
}