function fontawesome_check_installed in Font Awesome Icons 8.2
Check to make sure that Font Awesome is installed.
Return value
bool Flag indicating if the library is properly installed.
2 calls to fontawesome_check_installed()
- fontawesome_page_attachments in ./
fontawesome.module - Implements hook_page_attachments().
- fontawesome_requirements in ./
fontawesome.install - Implements hook_requirements().
File
- ./
fontawesome.module, line 196 - Drupal integration with Font Awesome, the iconic font for use with Bootstrap.
Code
function fontawesome_check_installed() {
// Load the configuration settings.
$configuration_settings = \Drupal::config('fontawesome.settings');
// If this module is not configured to load the fontawesome assets, exit.
if (!$configuration_settings
->get('load_assets')) {
return TRUE;
}
// Throw error if library file not found.
if ($configuration_settings
->get('use_cdn')) {
return !empty($configuration_settings
->get('external_svg_location'));
}
elseif ($configuration_settings
->get('method') == 'webfonts') {
// Webfonts method.
$fontawesome_library = \Drupal::service('library.discovery')
->getLibraryByName('fontawesome', 'fontawesome.webfonts');
return file_exists(DRUPAL_ROOT . '/' . $fontawesome_library['css'][0]['data']);
}
else {
// SVG method.
$fontawesome_library = \Drupal::service('library.discovery')
->getLibraryByName('fontawesome', 'fontawesome.svg');
return file_exists(DRUPAL_ROOT . '/' . $fontawesome_library['js'][0]['data']);
}
}