Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AjaxPageState.php

class AjaxPageState

Expands the compressed ajax_page_state query parameter into an array.

Hierarchy

  • class \Drupal\Core\StackMiddleware\AjaxPageState implements \Symfony\Component\HttpKernel\HttpKernelInterface

Expanded class hierarchy of AjaxPageState

File

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

Namespace

Drupal\Core\StackMiddleware
View source
class AjaxPageState implements HttpKernelInterface {
    
    /**
     * Constructs a new AjaxPageState instance.
     *
     * @param \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel
     *   The wrapped HTTP kernel.
     */
    public function __construct(HttpKernelInterface $httpKernel) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) : Response {
        if ($type === static::MAIN_REQUEST) {
            if ($request->request
                ->has('ajax_page_state')) {
                $request->request
                    ->set('ajax_page_state', $this->parseAjaxPageState($request->request
                    ->all('ajax_page_state')));
            }
            elseif ($request->query
                ->has('ajax_page_state')) {
                $request->query
                    ->set('ajax_page_state', $this->parseAjaxPageState($request->query
                    ->all('ajax_page_state')));
            }
        }
        return $this->httpKernel
            ->handle($request, $type, $catch);
    }
    
    /**
     * Parse the ajax_page_state variable in the request.
     *
     * Decompresses the libraries array key.
     *
     * @param array $ajax_page_state
     *   An array of query parameters, where the libraries parameter is compressed.
     *
     * @return array
     */
    private function parseAjaxPageState(array $ajax_page_state) : array {
        $ajax_page_state['libraries'] = UrlHelper::uncompressQueryParameter($ajax_page_state['libraries']);
        return $ajax_page_state;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
AjaxPageState::handle public function Handles a Request to convert it to a Response. Overrides HttpKernelInterface::handle
AjaxPageState::parseAjaxPageState private function Parse the ajax_page_state variable in the request.
AjaxPageState::__construct public function Constructs a new AjaxPageState instance.
HttpKernelInterface::MAIN_REQUEST public constant
HttpKernelInterface::SUB_REQUEST public constant

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal