You are here

public function AMPService::mapJSToNames in Accelerated Mobile Pages (AMP) 8.3

Map Drupal library names to the urls of the javascript they include.

Return value

array An array keyed by library names of the javascript urls in each library.

2 calls to AMPService::mapJSToNames()
AMPService::addComponentLibraries in src/Service/AMPService.php
Given an array of discovered JS requirements, identify related libraries.
AMPService::getComponentTags in src/Service/AMPService.php
Given an array of discovered JS requirements, identify the amp tags.

File

src/Service/AMPService.php, line 86

Class

AMPService
Class AMPService.

Namespace

Drupal\amp\Service

Code

public function mapJSToNames() {
  $libraries = [];
  $definitions = \Drupal::service('library.discovery')
    ->getLibrariesByExtension('amp');
  foreach ($definitions as $name => $definition) {
    if (!empty($definition['js'])) {
      $url = $definition['js'][0]['data'];
      $libraries[$url] = 'amp/' . $name;
    }
  }
  return $libraries;
}