You are here

public function FontAwesomeManager::getCategoryMetadata in Font Awesome Icons 8.2

Loads the Font Awesome category metadata.

Return value

array The available FontAwesome category metadata.

1 call to FontAwesomeManager::getCategoryMetadata()
FontAwesomeManager::getCategories in src/FontAwesomeManager.php
Get categories.

File

src/FontAwesomeManager.php, line 259

Class

FontAwesomeManager
Icon Manager Service for Font Awesome.

Namespace

Drupal\fontawesome

Code

public function getCategoryMetadata() {

  // Allow modules and themes to provide their own icon metadata first. If
  // none are provided, use the default metadata file.

  /** @var \Drupal\Component\Discovery\YamlDiscovery $yaml_discovery */
  $yaml_discovery = new YamlDiscovery('fontawesome.categorylist', $this->themeHandler
    ->getThemeDirectories() + $this->moduleHandler
    ->getModuleDirectories());
  $data = $yaml_discovery
    ->findAll();
  $metadata = [];
  if (!empty($data)) {
    foreach ($data as $categories) {
      $metadata = array_merge_recursive($metadata, $categories);
    }
  }
  else {
    $metadata = Yaml::parse(file_get_contents($this
      ->getCategoryMetadataFilepath()));
  }
  $this->moduleHandler
    ->alter('fontawesome_metadata_categories', $metadata);
  return $metadata;
}