You are here

class DisableDeriver in Drupal 7 to 8/9 Module Upgrader 8

Builds derivative definitions for the _disable plugin, based on a bundled configuration file. This allows us (plugin authors) to easily define which function calls can be commented out.

Hierarchy

Expanded class hierarchy of DisableDeriver

File

src/Plugin/DMU/Converter/Functions/DisableDeriver.php, line 12

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions
View source
class DisableDeriver extends DeriverBase {

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_definition) {
    $derivatives = [];
    $config = \Drupal::config('drupalmoduleupgrader.functions')
      ->get('definitions');
    foreach ($config as $key => $info) {

      // Only disable functions that have been explicitly marked for disabling.
      if (empty($info['disable'])) {
        continue;
      }

      // $key can either be the name of a single function, or an arbitrary string
      // identifying a group of functions to handle.
      if (empty($info['functions'])) {
        $info['functions'] = [
          $key,
        ];
      }
      foreach ($info['functions'] as $function) {
        $derivative = $base_definition;
        $variables = [
          '@function' => $function . '()',
        ];
        $derivative['function'] = $function;
        $derivative['description'] = $this
          ->t('Disables calls to @function().', $variables);
        if (isset($info['fixme'])) {
          $derivative['fixme'] = $this
            ->t($info['fixme'], $variables);
        }
        $derivative['documentation'] = $info['documentation'];
        $derivatives[$function] = $derivative;
      }
    }
    return $derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create 3
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
DeriverBase::__construct public function 3
DisableDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface::getDerivativeDefinitions
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.