You are here

public function PatternBase::getLibraryDefinitions in UI Patterns 8

Get library definitions for current pattern.

Return value

array Library definitions array.

Overrides PatternInterface::getLibraryDefinitions

See also

ui_patterns_library_info_build()

File

src/Plugin/PatternBase.php, line 70

Class

PatternBase
Class PatternBase.

Namespace

Drupal\ui_patterns\Plugin

Code

public function getLibraryDefinitions() {

  // @codingStandardsIgnoreStart
  $libraries = [];
  $definition = $this
    ->getPluginDefinition();

  // Get only locally defined libraries.
  $items = array_filter($definition['libraries'], function ($library) {
    return is_array($library);
  });

  // Attach pattern base path to assets.
  if (!empty($definition['base path'])) {
    $base_path = str_replace($this->root, '', $definition['base path']);
    $this
      ->processLibraries($items, $base_path);
  }

  // Produce final libraries array.
  $id = $definition['id'];
  array_walk($items, function ($value) use (&$libraries, $id) {
    $libraries[$id . '.' . key($value)] = reset($value);
  });

  // @codingStandardsIgnoreEnd
  return $libraries;
}