Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / VariableSet.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
4
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7 use Pharborist\Objects\ClassMethodCallNode;
8
9 /**
10  * @Converter(
11  *  id = "variable_set",
12  *  description = @Translation("Replaces variable_set() calls with Configuration API.")
13  * )
14  */
15 class VariableSet extends VariableAPI {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function rewrite(FunctionCallNode $call, TargetInterface $target) {
21     if ($this->tryRewrite($call, $target)) {
22       $arguments = $call->getArguments();
23
24       return ClassMethodCallNode::create('\Drupal', 'configFactory')
25         ->appendMethodCall('getEditable')
26         ->appendArgument($target->id() . '.settings')
27         ->appendMethodCall('set')
28         ->appendArgument(clone $arguments[0])
29         ->appendArgument(clone $arguments[1])
30         ->appendMethodCall('save');
31     }
32   }
33
34 }