function AjaxPageState::parseAjaxPageState

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php \Drupal\Core\StackMiddleware\AjaxPageState::parseAjaxPageState()
  2. 10 core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php \Drupal\Core\StackMiddleware\AjaxPageState::parseAjaxPageState()

Parse the ajax_page_state variable in the request.

Decompresses the libraries array key.

Parameters

array $ajax_page_state: An array of query parameters, where the libraries parameter is compressed.

Return value

array The input array of query parameters, where the libraries parameter is changed to be uncompressed.

1 call to AjaxPageState::parseAjaxPageState()
AjaxPageState::handle in core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php

File

core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php, line 87

Class

AjaxPageState
Expands the compressed ajax_page_state query parameter into an array.

Namespace

Drupal\Core\StackMiddleware

Code

private function parseAjaxPageState(array $ajax_page_state) : array {
  if (isset($ajax_page_state['libraries'])) {
    $libraries = explode(',', UrlHelper::uncompressQueryParameter($ajax_page_state['libraries']));
    // A library name always consists of an extension and a library name,
    // separated by a slash.
    $libraries = array_filter($libraries, static fn(string $library): bool => str_contains($library, '/'));
    if ($libraries) {
      $ajax_page_state['libraries'] = implode(',', $libraries);
    }
    else {
      unset($ajax_page_state['libraries']);
    }
  }
  return $ajax_page_state;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.