function LibraryDependencyResolver::doProcessBeforeAfter

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php \Drupal\Core\Asset\LibraryDependencyResolver::doProcessBeforeAfter()

Processes before and after settings for the libraries graph.

Parameters

array $graph: The libraries graph array.

Return value

array The libraries graph with before and after processed.

1 call to LibraryDependencyResolver::doProcessBeforeAfter()
LibraryDependencyResolver::getLibrariesWithDependencies in core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php
Gets the given libraries with their dependencies.

File

core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php, line 93

Class

LibraryDependencyResolver
Resolves the dependencies of asset (CSS/JavaScript) libraries.

Namespace

Drupal\Core\Asset

Code

protected function doProcessBeforeAfter($graph) : array {
  foreach ($graph as $library => $data) {
    [$extension, $name] = explode('/', $library, 2);
    $definition = $this->libraryDiscovery
      ->getLibraryByName($extension, $name) + [
      'after' => [],
      'before' => [],
    ];
    foreach ($definition['after'] as $after) {
      if (isset($graph[$after])) {
        $graph[$library]['edges'][$after] = $after;
      }
    }
    foreach ($definition['before'] as $before) {
      if (isset($graph[$before])) {
        $graph[$before]['edges'][$library] = $library;
      }
    }
  }
  return $graph;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.