public function VariableGet::convert in Drupal 7 to 8/9 Module Upgrader 8
Performs required conversions.
Parameters
TargetInterface $target: The target module to convert.
Overrides FunctionCallModifier::convert
File
- src/
Plugin/ DMU/ Converter/ Functions/ VariableGet.php, line 70
Class
- VariableGet
- Plugin annotation @Converter( id = "variable_get", description = @Translation("Replaces variable_get() calls with Configuration API.") )
Namespace
Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\FunctionsCode
public function convert(TargetInterface $target) {
parent::convert($target);
if ($this->defaults && $this->schema) {
$group = $target
->id() . '.settings';
$this
->write($target, InstallStorage::CONFIG_INSTALL_DIRECTORY . '/' . $group . '.yml', Yaml::encode($this->defaults));
$this->defaults = [];
$schema = [
$group => [
'type' => 'mapping',
'label' => (string) $this
->t('Settings'),
'mapping' => $this->schema,
],
];
$this
->write($target, InstallStorage::CONFIG_SCHEMA_DIRECTORY . '/' . $target
->id() . '.schema.yml', Yaml::encode($schema));
$this->schema = [];
}
}