function simple_fb_connect_update_8302 in Simple FB Connect 8.3
Enables Simple FB Connect - Rules Integration if needed.
Rules support was moved to a separate sub module in release 8.x-3.1. This update automatically enables the sub module if the site has Rules events that react to Simple FB Connect events.
File
- ./
simple_fb_connect.install, line 120 - Install, update, and uninstall functions for the Simple FB Connect module.
Code
function simple_fb_connect_update_8302(&$sandbox) {
// Check if Rules is enabled.
if (\Drupal::service('module_handler')
->moduleExists('rules')) {
// Check if we have Rules reacting to Simple FB Connect events.
$simple_fb_connect_rules = [
'simple_fb_connect.user_login',
'simple_fb_connect.user_create',
];
$simple_fb_connect_rules_exists = FALSE;
$rules = \Drupal::service('entity.manager')
->getStorage('rules_reaction_rule')
->loadMultiple();
foreach ($rules as $rule) {
if (array_intersect($simple_fb_connect_rules, $rule
->getEventNames())) {
$simple_fb_connect_rules_exists = TRUE;
break;
}
}
// Enable simple_fb_connect_rules if rules were found.
if ($simple_fb_connect_rules_exists) {
\Drupal::service('module_installer')
->install([
'simple_fb_connect_rules',
]);
}
}
}