resetImplementations(); } /** @noinspection PhpInconsistentReturnPointsInspection */ /** * Implements hook_module_implementation_alter(). * * Disables configured hooks. * @param $implementations * @param $hook * @return null */ public static function alter(&$implementations, $hook) { if (!static::$alterActive) { return NULL; } if (!$implementations) { return NULL; } $hooks = static::getConfig('hooks'); $modules = static::getConfig('modules'); $disabled = []; // Disable by hook + module if (array_key_exists($hook, $hooks)) { $disabled = array_intersect_key($implementations, array_flip($hooks[$hook])); } // Disable by module $disabled += array_intersect_key($implementations, array_flip($modules)); $implementations = array_diff_key($implementations, $disabled); /** @noinspection PhpUnusedParameterInspection */ array_walk($disabled, function ($el, $key) use ($hook) { error_log('DISABLED: ' . $key . '_' . $hook); }); } /** * Helper functions * * @param $key * @return array */ protected static function getConfig($key) { if (!static::$config) { static::$config = \Drupal::config('migrate_booster.settings')->get(); } if ($key && isset(static::$config[$key])) { return static::$config[$key]; } return []; } }