fontawesome.install in Font Awesome Icons 8
Same filename and directory in other branches
Requirements page for Font Awesome.
File
fontawesome.installView source
<?php
/**
* @file
* Requirements page for Font Awesome.
*/
/**
* Implements hook_requirements().
*/
function fontawesome_requirements($phase) {
$requirements = [];
// Report the version of Font Awesome.
if ($phase == 'runtime') {
$requirements['fontawesome'] = [
'title' => t('Fontawesome'),
];
// Don't really check for Font Awesome if we are using the CDN version.
if (\Drupal::config('fontawesome.settings')
->get('fontawesome_use_cdn')) {
$fontawesome_library = \Drupal::service('library.discovery')
->getLibraryByName('fontawesome', 'fontawesome.cdn');
$requirements['fontawesome']['severity'] = REQUIREMENT_OK;
$requirements['fontawesome']['value'] = t('Using CDN version: %version', [
'%version' => $fontawesome_library['css'][0]['data'],
]);
}
else {
// Verify the library is installed.
$fontawesome_library = \Drupal::service('library.discovery')
->getLibraryByName('fontawesome', 'fontawesome');
if (file_exists(DRUPAL_ROOT . '/' . $fontawesome_library['css'][0]['data'])) {
$requirements['fontawesome']['severity'] = REQUIREMENT_OK;
$requirements['fontawesome']['value'] = t('Font Awesome library is installed.');
}
else {
$requirements['fontawesome']['severity'] = REQUIREMENT_WARNING;
$requirements['fontawesome']['value'] = t('Font Awesome library is not installed. View the README for more information on installing Font Awesome.');
}
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function fontawesome_uninstall() {
// Delete set variables.
$query = \Drupal::database()
->delete('config');
$query
->condition('name', 'fontawesome.settings');
$query
->execute();
$query = \Drupal::database()
->delete('key_value');
$query
->condition('name', 'fontawesome');
$query
->execute();
// Icon API module : Delete fontawesome icon bundle & clear cache.
if (\Drupal::moduleHandler()
->moduleExists('icon') && ($cache = \Drupal::cache()
->get('icon_bundles')) && !empty($cache->data)) {
$fa_icon_bundle = isset($cache->data['fontawesome']) ? $cache->data['fontawesome'] : [];
$fa_icon_bundle['path'] = isset($fa_icon_bundle['path']) ? $fa_icon_bundle['path'] : 'fontawesome';
icon_bundle_delete($fa_icon_bundle);
}
}
Functions
Name | Description |
---|---|
fontawesome_requirements | Implements hook_requirements(). |
fontawesome_uninstall | Implements hook_uninstall(). |