1 icon.inc _icon_from_module($icon_name)

Checks if a theme provides an icon.

Do not call this function directly. Use icon() instead.

@private

Parameters

string $icon_name: The icon name to be located.

Return value

string|void: The path to the icon if found.

See also

icon()

File

core/includes/icon.inc, line 187
Provides the Backdrop API for placing icons.

Code

function _icon_from_module($icon_name) {
  $icon_info = icon_get_info($icon_name);
  if ($icon_info) {
    if (isset($icon_info['directory'])) {
      $directory = $icon_info['directory'];
    }
    else {
      $directory = backdrop_get_path('module', $icon_info['module']) . '/icons';
    }
    if (isset($icon_info['name'])) {
      $filename = $icon_info['name'] . '.svg';
    }
    else {
      $filename = $icon_name . '.svg';
    }
    $module_icon_path = $directory . '/' . $filename;
    if (file_exists($module_icon_path)) {
      return $module_icon_path;
    }
  }
}