VariableAPI.php in Drupal 7 to 8/9 Module Upgrader 8
File
src/Plugin/DMU/Converter/Functions/VariableAPI.php
View source
<?php
namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
use Drupal\drupalmoduleupgrader\TargetInterface;
use Pharborist\Functions\FunctionCallNode;
use Pharborist\Types\StringNode;
abstract class VariableAPI extends FunctionCallModifier {
protected function tryRewrite(FunctionCallNode $call, TargetInterface $target) {
$statement = $call
->getStatement();
$arguments = $call
->getArguments();
if ($arguments[0] instanceof StringNode) {
$key = $arguments[0]
->toValue();
if (strpos($key, $target
->id() . '_') === 0) {
return TRUE;
}
else {
$comment = <<<END
This looks like another module's variable. You'll need to rewrite this call
to ensure that it uses the correct configuration object.
END;
$this
->buildFixMe($comment)
->prependTo($statement);
return FALSE;
}
}
else {
$comment = <<<END
The correct configuration object could not be determined. You'll need to
rewrite this call manually.
END;
$this
->buildFixMe($comment)
->prependTo($statement);
return FALSE;
}
}
}
Classes
Name |
Description |
VariableAPI |
Parent class of the VariableGet, VariableSet, and VariableDel plugins. |