3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
5 use Drupal\drupalmoduleupgrader\DeriverBase;
8 * Builds derivative definitions for the _disable plugin, based on a bundled configuration
9 * file. This allows us (plugin authors) to easily define which function calls can be
12 class DisableDeriver extends DeriverBase {
17 public function getDerivativeDefinitions($base_definition) {
20 $config = \Drupal::config('drupalmoduleupgrader.functions')->get('definitions');
21 foreach ($config as $key => $info) {
22 // Only disable functions that have been explicitly marked for disabling.
23 if (empty($info['disable'])) {
27 // $key can either be the name of a single function, or an arbitrary string
28 // identifying a group of functions to handle.
29 if (empty($info['functions'])) {
30 $info['functions'] = [$key];
33 foreach ($info['functions'] as $function) {
34 $derivative = $base_definition;
35 $variables = ['@function' => $function . '()'];
37 $derivative['function'] = $function;
38 $derivative['description'] = $this->t('Disables calls to @function().', $variables);
39 if (isset($info['fixme'])) {
40 $derivative['fixme'] = $this->t($info['fixme'], $variables);
42 $derivative['documentation'] = $info['documentation'];
44 $derivatives[$function] = $derivative;