Same name in other branches
- 5.0.x advagg.module \advagg_enabled()
- 6.0.x advagg.module \advagg_enabled()
- 7.x-2.x advagg.module \advagg_enabled()
- 8.x-3.x advagg.module \advagg_enabled()
- 8.x-4.x advagg.module \advagg_enabled()
Function used to see if aggregation is enabled.
Return value
bool The value of the advagg_enabled variable.
5 calls to advagg_enabled()
- advagg_css_alter dans ./
advagg.module - Implements hook_css_alter().
- advagg_js_alter dans ./
advagg.module - Implements hook_js_alter().
- advagg_mod_advagg_asset_render_alter dans advagg_mod/
advagg_mod.module - Implements hook_advagg_asset_render_alter().
- advagg_mod_css_alter dans advagg_mod/
advagg_mod.module - Implements hook_css_alter().
- advagg_mod_js_alter dans advagg_mod/
advagg_mod.module - Implements hook_js_alter().
1 string reference to 'advagg_enabled'
- d7_advagg_settings.yml dans migration_templates/
d7_advagg_settings.yml - migration_templates/d7_advagg_settings.yml
Fichier
-
./
advagg.module, line 327
Code
function advagg_enabled() {
$init =& drupal_static(__FUNCTION__);
if (!empty($init)) {
return $init['advagg'];
}
$advagg_config = \Drupal::config('advagg.settings');
$user = \Drupal::currentUser();
$init['advagg'] = $advagg_config->get('enabled');
// Disable AdvAgg if maintenance mode is defined.
if (defined('MAINTENANCE_MODE')) {
$init['advagg'] = FALSE;
return FALSE;
}
// Allow for AdvAgg to be enabled/disabled per request.
if (isset($_GET['advagg']) && $user->hasPermission('bypass advanced aggregation')) {
if ($_GET['advagg'] == 1) {
$init['advagg'] = TRUE;
}
else {
$init['advagg'] = FALSE;
}
}
// Do not use AdvAgg if the disable cookie is set.
$cookie_name = 'AdvAggDisabled';
$key = Crypt::hashBase64(\Drupal::service('private_key')->get());
if (!empty($_COOKIE[$cookie_name]) && $_COOKIE[$cookie_name] == $key) {
$init['advagg'] = FALSE;
// Let the user know that the AdvAgg bypass cookie is currently set.
static $msg_set;
if (!isset($msg_set) && $advagg_config->get('show_bypass_cookie_message')) {
$msg_set = TRUE;
if (\Drupal::currentUser()->hasPermission('administer site configuration')) {
drupal_set_message(t('The AdvAgg bypass cookie is currently enabled. Turn it off by going to the <a href="@advagg_operations">AdvAgg Operations</a> page and clicking the <em>Toggle the "aggregation bypass cookie" for this browser</em> button.', [
'@advagg_operations' => Url::fromRoute('advagg.operations', [], [
'fragment' => 'edit-bypass',
])->toString(),
]));
}
else {
drupal_set_message(t('The AdvAgg bypass cookie is currently enabled. Turn it off by <a href="@login">logging in</a> with a user with the "administer site configuration" permissions and going to the AdvAgg Operations page (located at @advagg_operations) and clicking the <em>Toggle the "aggregation bypass cookie" for this browser</em> button.', [
'@login' => '/user/login',
'@advagg_operations' => Url::fromRoute('advagg.operations')->toString(),
]));
}
}
}
// Enable debugging if requested.
if (isset($_GET['advagg-debug']) && $_GET['advagg-debug'] == 1 && $user->hasPermission('bypass advanced aggregation')) {
global $config;
$config['advagg.settings']['debug'] = TRUE;
}
return $init['advagg'];
}