function responsive_menus_style_load in Responsive Menus 8
Same name and namespace in other branches
- 7 responsive_menus.module \responsive_menus_style_load()
Load a single style.
Parameters
string $style: Style id to be loaded.
1 call to responsive_menus_style_load()
- responsive_menus_context_options_form in includes/
context/ responsive_menus_context.inc - Options form callack for context integration.
File
- ./
responsive_menus.module, line 127 - Responsify menus in Drupal.
Code
function responsive_menus_style_load($style, $jq_update_ignore) {
$link_generator = \Drupal::service('link_generator');
$styles = \Drupal::service('plugin.manager.responsive_menus')
->getDefinitions();
$data =& drupal_static(__FUNCTION__, []);
if (!isset($data[$style]) && !empty($styles[$style])) {
$style_info = $styles[$style];
// @todo module_load_include() the .inc file for the style being loaded.
// Check for this style's requirements.
if (!empty($style_info['jquery_version'])) {
if (!$jq_update_ignore[1]) {
if (!\Drupal::moduleHandler()
->moduleExists('jquery_update')) {
// jQuery Update not installed.
\Drupal::messenger()
->addWarning(t('@style style requires !link set to version !version or higher. Please enable jquery_update.', [
'@style' => $style_info['name'],
'!link' => $link_generator
->generate(t('jQuery Update'), Url::fromUri('http://drupal.org/project/jquery_update')),
'!version' => $style_info['jquery_version'],
]));
$error = TRUE;
}
// elseif (version_compare(variable_get('jquery_update_jquery_version', '1.5'), $style_info['jquery_version'], '<')) {
// // jQuery Update version not high enough.
// drupal_set_message(t('@style style requires !link set to version !version or higher.', [
// '@style' => $style_info['name'],
// '!version' => $style_info['jquery_version'],
// '!link' => l(t('jQuery Update'), 'admin/config/development/jquery_update', ['query' => ['destination' => 'admin/config/user-interface/responsive_menus']]),
// ]), 'warning');
// $error = TRUE;
// }
}
else {
\Drupal::messenger()
->addWarning(t('@style style requires !link library version !version or higher, but you have opted to provide your own library. Please ensure you have the proper version of jQuery included. (note: this is not an error)', [
'@style' => $style_info['name'],
'!link' => $link_generator
->generate(t('jQuery'), Url::fromUri('http://jquery.com')),
'!version' => $style_info['jquery_version'],
]));
}
}
// For integration with Libraries.
if (isset($style_info['use_libraries'])) {
// Try libraries module.
if (\Drupal::moduleHandler()
->moduleExists('libraries')) {
// if ($library = libraries_load($style_info['library'])) {
// if (!empty($library['error']) || empty($library['loaded'])) {
// drupal_set_message(t('!message !link and extract to your libraries directory as "@library_name". Example: sites/all/libraries/@library_name. If you are getting "version detection" errors, check file permissions on the library.', [
// '!message' => $library['error message'],
// '@library_name' => $style_info['library'],
// '!link' => l(t('Download it'), $library['download url']),
// ]), 'error');
// $error = TRUE;
// }
// }
}
else {
// Libraries module not installed.
\Drupal::messenger()
->addWarning(t('@style style requires !link module enabled.', [
'@style' => $style_info['name'],
'!link' => $link_generator
->generate(t('Libraries 2.x'), Url::fromUri('http://drupal.org/project/libraries')),
]));
$error = TRUE;
}
}
// Check for errors and load into $data if there are none.
if (!isset($error)) {
$data[$style] = $style_info;
return $data[$style];
}
else {
// Something was wrong loading this style.
\Drupal::messenger()
->addError(t('Responsive Menus found a problem. Please check the errors.'));
return FALSE;
}
}
else {
// This style is already loaded.
return $data[$style];
}
}