optimizeGroup example

$mock_file_system = $this->createMock(FileSystemInterface::class);
    $mock_config_factory = $this->createMock(ConfigFactoryInterface::class);
    $mock_file_url_generator = $this->createMock(FileUrlGeneratorInterface::class);
    $mock_time = $this->createMock(TimeInterface::class);
    $mock_language = $this->createMock(LanguageManagerInterface::class);
    $optimizer = new CssCollectionOptimizerLazy($mock_grouper$mock_optimizer$mock_theme_manager$mock_dependency_resolvernew RequestStack()$mock_file_system$mock_config_factory$mock_file_url_generator$mock_time$mock_language$mock_state);
    $gpl_license = [
      'name' => 'GNU-GPL-2.0-or-later',
      'url' => 'https://www.drupal.org/licensing/faq',
      'gpl-compatible' => TRUE,
    ];
    $aggregate = $optimizer->optimizeGroup(
      [
        'items' => [
          'core/modules/system/tests/modules/common_test/common_test_css_import.css' => [
            'type' => 'file',
            'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css',
            'preprocess' => TRUE,
            'license' => $gpl_license,
          ],
          'core/modules/system/tests/modules/common_test/common_test_css_import_not_preprocessed.css' => [
            'type' => 'file',
            'data' => 'core/modules/system/tests/modules/common_test/common_test_css_import.css',
            
if (!$exclude_string) {
        throw new BadRequestHttpException('The libraries to exclude are encoded incorrectly.');
      }
      $attached_assets->setAlreadyLoadedLibraries(explode(',', $exclude_string));
    }
    $groups = $this->getGroups($attached_assets$request);

    $group = $this->getGroup($groups$request->query->get('delta'));
    // Generate a hash based on the asset group, this uses the same method as     // the collection optimizer does to create the filename, so it should match.     $generated_hash = $this->generateHash($group);
    $data = $this->optimizer->optimizeGroup($group);

    // However, the hash from the library definitions in code may not match the     // hash from the URL. This can be for three reasons:     // 1. Someone has requested an outdated URL, i.e. from a cached page, which     // matches a different version of the code base.     // 2. Someone has requested an outdated URL during a deployment. This is     // the same case as #1 but a much shorter window.     // 3. Someone is attempting to craft an invalid URL in order to conduct a     // denial of service attack on the site.     // Dump the optimized group into an aggregate file, but only if the     // received hash and generated hash match. This prevents invalid filenames
Home | Imprint | This part of the site doesn't use cookies.