Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / VariableDel.php
diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/VariableDel.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/VariableDel.php
new file mode 100644 (file)
index 0000000..965ca73
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
+
+use Drupal\drupalmoduleupgrader\TargetInterface;
+use Pharborist\Functions\FunctionCallNode;
+use Pharborist\Objects\ClassMethodCallNode;
+
+/**
+ * @Converter(
+ *  id = "variable_del",
+ *  description = @Translation("Replaces variable_del() calls with Configuration API.")
+ * )
+ */
+class VariableDel extends VariableAPI {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function rewrite(FunctionCallNode $call, TargetInterface $target) {
+    if ($this->tryRewrite($call, $target)) {
+      return ClassMethodCallNode::create('\Drupal', 'config')
+        ->appendArgument($target->id() . '.settings')
+        ->appendMethodCall('clear')
+        ->appendArgument(clone $call->getArguments()->get(0))
+        ->appendMethodCall('save');
+    }
+  }
+
+}