You are here

public function DefaultProcessor::processElement in Cookie Content Blocker 8

Processes the element.

Parameters

array $element: The element to process.

Return value

array The processed element.

Overrides ElementProcessorBase::processElement

File

src/ElementProcessor/DefaultProcessor.php, line 46

Class

DefaultProcessor
Class DefaultProcessor.

Namespace

Drupal\cookie_content_blocker\ElementProcessor

Code

public function processElement(array $element) : array {
  $config = $this->configFactory
    ->get('cookie_content_blocker.settings');
  $element['#theme_wrappers'] = $element['#theme_wrappers'] ?? [];
  $element['#theme_wrappers'][] = 'cookie_content_blocker_wrapper';
  if (!is_array($element['#cookie_content_blocker'])) {
    $element['#cookie_content_blocker'] = [];
  }
  $defaults = [
    'blocked_message' => $config
      ->get('blocked_message'),
    'show_button' => $config
      ->get('show_button'),
    'button_text' => $config
      ->get('button_text'),
    'enable_click' => $config
      ->get('enable_click_consent_change'),
    'show_placeholder' => TRUE,
    'preview' => [],
  ];
  $element['#cookie_content_blocker'] = array_merge($defaults, $element['#cookie_content_blocker']);
  return $element;
}