Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / DisableDeriver.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
4
5 use Drupal\drupalmoduleupgrader\DeriverBase;
6
7 /**
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
10  * commented out.
11  */
12 class DisableDeriver extends DeriverBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function getDerivativeDefinitions($base_definition) {
18     $derivatives = [];
19
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'])) {
24         continue;
25       }
26
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];
31       }
32
33       foreach ($info['functions'] as $function) {
34         $derivative = $base_definition;
35         $variables = ['@function' => $function . '()'];
36
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);
41         }
42         $derivative['documentation'] = $info['documentation'];
43
44         $derivatives[$function] = $derivative;
45       }
46     }
47
48     return $derivatives;
49   }
50
51 }