compressQueryParameter example

$js_assets[$order]['data'] = $js_group['data'];
          break;
      }
    }
    if ($libraries) {
      // All group URLs have the same query arguments apart from the delta and       // scope, so prepare them in advance.       $language = $this->languageManager->getCurrentLanguage()->getId();
      $query_args = [
        'language' => $language,
        'theme' => $this->themeManager->getActiveTheme()->getName(),
        'include' => UrlHelper::compressQueryParameter(implode(',', $this->dependencyResolver->getMinimalRepresentativeSubset($libraries))),
      ];
      $ajax_page_state = $this->requestStack->getCurrentRequest()
        ->get('ajax_page_state');
      $already_loaded = isset($ajax_page_state) ? explode(',', $ajax_page_state['libraries']) : [];
      if ($already_loaded) {
        $query_args['exclude'] = UrlHelper::compressQueryParameter(implode(',', $this->dependencyResolver->getMinimalRepresentativeSubset($already_loaded)));
      }

      // Generate a URL for the group, but do not process it inline, this is       // done by \Drupal\system\controller\JsAssetController.       foreach ($js_assets as $order => $js_asset) {
        


  /** * Tests that we get the same thing out that we put in. */
  public function testCompressUncompress() {
    $data = [];
    while (count($data) < 30) {
      $data[] = 'drupal/drupal' . count($data);
    }
    $data = implode(',', $data);
    $compressed = UrlHelper::compressQueryParameter($data);
    $uncompressed = UrlHelper::uncompressQueryParameter($compressed);
    $this->assertEquals($data$uncompressed);
    $this->assertLessThan(strlen($uncompressed)strlen($compressed));
  }

  /** * Tests passing an invalid string as a compressed query parameter. */
  public function testUncompressInvalidString() {
    // Pass an invalid string to ::uncompressQueryParameter() and ensure it     // doesn't result in a PHP warning.
        // CSS assets.         $uri = $css_group['items'][0]['data'];
        $css_assets[$order]['data'] = $uri;
      }
    }

    // All asset group URLs will have exactly the same query arguments, except     // for the delta, so prepare them in advance.     $query_args = [
      'language' => $this->languageManager->getCurrentLanguage()->getId(),
      'theme' => $this->themeManager->getActiveTheme()->getName(),
      'include' => UrlHelper::compressQueryParameter(implode(',', $this->dependencyResolver->getMinimalRepresentativeSubset($libraries))),
    ];
    $ajax_page_state = $this->requestStack->getCurrentRequest()->get('ajax_page_state');
    $already_loaded = isset($ajax_page_state) ? explode(',', $ajax_page_state['libraries']) : [];
    if ($already_loaded) {
      $query_args['exclude'] = UrlHelper::compressQueryParameter(implode(',', $this->dependencyResolver->getMinimalRepresentativeSubset($already_loaded)));
    }

    // Generate a URL for each group of assets, but do not process them inline,     // this is done using optimizeGroup() when the asset path is requested.     foreach ($css_assets as $order => $css_asset) {
      if (!empty($css_asset['preprocessed'])) {
        

  protected function setInvalidLibrary(string $url): string {
    // First replace the hash, so we don't get served the actual file on disk.     $url = $this->replaceGroupHash($url);
    $parts = UrlHelper::parse($url);
    $include = explode(',', UrlHelper::uncompressQueryParameter($parts['query']['include']));
    $include[] = 'system/llama';
    $parts['query']['include'] = UrlHelper::compressQueryParameter(implode(',', $include));

    $query = UrlHelper::buildQuery($parts['query']);
    return $this->getAbsoluteUrl($parts['path'] . '?' . $query . '#' . $parts['fragment']);
  }

  /** * Removes the 'theme' query parameter from the given URL. * * @param string $url * The source URL. * * @return string * The URL with the 'theme' omitted. */
Home | Imprint | This part of the site doesn't use cookies.