static function Helpers::calendar_systems_is_patch_applied in Calendar Systems 8.2
Internal helper to check whether the required patch is applied or not.
Return value
Boolean value.
1 call to Helpers::calendar_systems_is_patch_applied()
- AdminSettings::buildForm in src/
Form/ AdminSettings.php - Form constructor.
File
- src/
Helpers.php, line 236 - Contains \Drupal\calendar_systems.
Class
Namespace
Drupal\calendar_systemsCode
static function calendar_systems_is_patch_applied($cache = TRUE) {
static $result;
if ($cache) {
$cache_object = \Drupal::cache()
->get('calendar_systems_is_patch_applied');
if (is_object($cache_object)) {
$result = $cache_object->data;
}
}
if (is_null($result)) {
$content = file_get_contents(DRUPAL_ROOT . '/core/includes/common.inc');
// Check against patch fingerprint:
$very_old_patch_applied = strpos($content, 'foreach (module_implements(\'format_date\') AS $module) {') !== FALSE ? TRUE : FALSE;
$old_patch_applied = strpos($content, 'foreach (module_implements(\'format_date_calendar_systems\') AS $module) {') !== FALSE ? TRUE : FALSE;
$applied = strpos($content, 'drupal_alter(\'format_date\'') !== FALSE ? TRUE : FALSE;
if ($applied) {
$result = TRUE;
}
elseif ($old_patch_applied || $very_old_patch_applied) {
$result = 'outdated';
}
else {
$result = FALSE;
}
\Drupal::cache()
->set('calendar_systems_is_patch_applied', $result, time() + 60 * 60);
}
return $result;
}