moment.install in Moment.js 8.2
Same filename and directory in other branches
Install, update and uninstall functions for the Moment.js module.
File
moment.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Moment.js module.
*/
/**
* Implements hook_requirements().
*/
function moment_requirements($phase) {
$requirements = [];
if ($phase === 'runtime') {
$library_discovery = \Drupal::service('library.discovery');
$libraries = [
'moment' => 'Moment.js',
];
foreach ($libraries as $name => $label) {
$library = $library_discovery
->getLibraryByName('moment', $name);
$severity = REQUIREMENT_OK;
foreach ($library['js'] as $js) {
if (!file_exists($js['data'])) {
$severity = REQUIREMENT_ERROR;
break;
}
}
$requirements["moment_library_{$name}"] = [
'title' => t('@label library version', [
'@label' => $label,
]),
'value' => $severity == REQUIREMENT_OK ? t('Available') : t('Not available'),
'severity' => $severity,
];
}
}
return $requirements;
}
Functions
Name![]() |
Description |
---|---|
moment_requirements | Implements hook_requirements(). |