You are here

public function MultipleAssetLibrary::getAttachableAssetLibraries in Libraries API 8.3

Returns a core library array structure for this library.

@todo Document the return value.

Parameters

\Drupal\libraries\ExternalLibrary\LibraryManagerInterface $library_manager: The library manager that can be used to fetch dependencies.

Return value

array

Throws

\Drupal\libraries\ExternalLibrary\Exception\InvalidLibraryDependencyException

\Drupal\libraries\ExternalLibrary\Exception\LibraryDefinitionNotFoundException

\Drupal\libraries\ExternalLibrary\Exception\LibraryTypeNotFoundException

\Drupal\Component\Plugin\Exception\PluginException

Overrides MultipleAssetLibraryInterface::getAttachableAssetLibraries

See also

\Drupal\libraries\ExternalLibrary\Asset\getAttachableAssetLibraries::getAttachableAssetLibraries()

File

src/ExternalLibrary/Asset/MultipleAssetLibrary.php, line 90

Class

MultipleAssetLibrary
Provides a class for a library with multiple attachable asset libraries.

Namespace

Drupal\libraries\ExternalLibrary\Asset

Code

public function getAttachableAssetLibraries(LibraryManagerInterface $library_manager) {
  if (!$this
    ->canBeAttached()) {
    throw new LibraryNotInstalledException($this);
  }
  $attachable_libraries = [];
  foreach ($this->libraries as $attachable_library_id => $attachable_library) {
    $attachable_libraries[$attachable_library_id] = [
      'version' => $this
        ->getVersion(),
      'css' => $this
        ->processCssAssets($attachable_library['css']),
      'js' => $this
        ->processJsAssets($attachable_library['js']),
      'dependencies' => $attachable_library['dependencies'],
    ];
  }
  return $attachable_libraries;
}