drowl_paragraphs_bs-1.x-dev/modules/drowl_paragraphs_bs_type_score/drowl_paragraphs_bs_type_score.install
modules/drowl_paragraphs_bs_type_score/drowl_paragraphs_bs_type_score.install
<?php
/**
* @file
* Install, update and uninstall functions for drowl_paragraphs_bs_type_score.
*/
/**
* Implements hook_requirements().
*/
function drowl_paragraphs_bs_type_score_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$library_definition = \Drupal::service('library.discovery')->getLibraryByName('drowl_paragraphs_bs_type_score', 'global');
$library = [];
if (!file_exists(DRUPAL_ROOT . '/' . $library_definition['js'][0]['data']) || !file_exists(DRUPAL_ROOT . '/' . $library_definition['css'][0]['data'])) {
$error_type = t('Missing progressbar.js library');
$error_message = t('Library not found in the "libraries" directory.');
if (empty($library['installed'])) {
$requirements['drowl_paragraphs_bs_type_score'] = [
'title' => t('DROWL Paragraphs for Bootstrap Type: Score'),
'value' => t('@e: At least @a', [
'@e' => $error_type,
'@a' => 'v1.1',
]),
'severity' => REQUIREMENT_ERROR,
'description' => t('@error You need to download the <a href=":url" target="_blank">progressbar.js library</a>, extract the archive and place it in the the %path directory on your server. Ensure the following file to exist: "/libraries/progressbar.js/dist/progressbar.min.js". Alternatively use ´composer require npm-asset/progressbar.js´.', [
'@error' => $error_message,
':url' => 'https://github.com/kimmobrunfeldt/progressbar.js',
'%path' => 'libraries',
]),
];
}
}
}
return $requirements;
}
