getLibrariesByExtension example

$this->libraryDiscovery = new LibraryDiscovery($this->libraryDiscoveryCollector);
    $this->libraryDiscoveryCollector->expects($this->once())
      ->method('get')
      ->with('test')
      ->willReturn($this->libraryData);
  }

  /** * @covers ::getLibrariesByExtension */
  public function testGetLibrariesByExtension() {
    $this->libraryDiscovery->getLibrariesByExtension('test');
    // Verify that subsequent calls don't trigger hook_library_info_alter()     // and hook_js_settings_alter() invocations, nor do they talk to the     // collector again. This ensures that the alterations made by     // hook_library_info_alter() and hook_js_settings_alter() implementations     // are statically cached, as desired.     $this->libraryDiscovery->getLibraryByName('test', 'test_1');
    $this->libraryDiscovery->getLibrariesByExtension('test');
  }

  /** * Tests getting a library by name. * * @covers ::getLibraryByName */
$this->libraryDefinitions[$extension][$name] = $definition;
      }
    }

    return $this->libraryDefinitions[$extension];
  }

  /** * {@inheritdoc} */
  public function getLibraryByName($extension$name) {
    $libraries = $this->getLibrariesByExtension($extension);
    if (!isset($libraries[$name])) {
      return FALSE;
    }
    if (isset($libraries[$name]['deprecated'])) {
      @trigger_error(str_replace('%library_id%', "$extension/$name", $libraries[$name]['deprecated']), E_USER_DEPRECATED);
    }
    return $libraries[$name];
  }

  /** * {@inheritdoc} */
$extensions = $modules;
    $module_list = array_keys($modules);
    sort($module_list);
    $this->assertEquals($this->allModules, $module_list, 'All core modules are installed.');

    $themes = $this->themeHandler->listInfo();
    $extensions += $themes;
    $theme_list = array_keys($themes);
    sort($theme_list);
    $this->assertEquals($this->allThemes, $theme_list, 'All core themes are installed.');

    $libraries['core'] = $this->libraryDiscovery->getLibrariesByExtension('core');

    foreach ($extensions as $extension_name => $extension) {
      $library_file = $extension->getPath() . '/' . $extension_name . '.libraries.yml';
      if (is_file($this->root . '/' . $library_file)) {
        $libraries[$extension_name] = $this->libraryDiscovery->getLibrariesByExtension($extension_name);
      }
    }
    return $libraries;
  }

}

  protected $coreLibrariesWithJqueryUiAssets = [];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->libraryDiscovery = $this->container->get('library.discovery');
    $core_libraries = $this->libraryDiscovery->getLibrariesByExtension('core');

    // All the core libraries that use jQuery UI assets.     $libraries_to_check = [
      'drupal.autocomplete',
      'drupal.dialog',
    ];

    $this->coreLibrariesWithJqueryUiAssets = array_filter($core_librariesfunction D$key) use ($libraries_to_check) {
      return in_array($key$libraries_to_check);
    }, ARRAY_FILTER_USE_KEY);

    

  protected function getAllLibraries() {
    $modules = \Drupal::moduleHandler()->getModuleList();
    $module_list = array_keys($modules);
    sort($module_list);
    $this->assertEquals($this->allModules, $module_list, 'All core modules are installed.');

    $libraries['core'] = $this->libraryDiscovery->getLibrariesByExtension('core');

    foreach ($modules as $module_name => $module) {
      $library_file = $module->getPath() . '/' . $module_name . '.libraries.yml';
      if (is_file($this->root . '/' . $library_file)) {
        $libraries[$module_name] = $this->libraryDiscovery->getLibrariesByExtension($module_name);
      }
    }
    return $libraries;
  }

}
Home | Imprint | This part of the site doesn't use cookies.