3 namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions;
5 use Drupal\drupalmoduleupgrader\TargetInterface;
6 use Pharborist\Functions\FunctionCallNode;
7 use Pharborist\Objects\ClassMethodCallNode;
12 * description = @Translation("Rewrites calls to cache_set().")
15 class CacheSet extends FunctionCallModifier {
20 public function rewrite(FunctionCallNode $call, TargetInterface $target) {
21 $arguments = $call->getArguments();
23 $cache = ClassMethodCallNode::create('\Drupal', 'cache');
24 if (sizeof($arguments) > 2) {
25 $cache->appendArgument(clone $arguments[2]);
28 $set = $cache->appendMethodCall('set')
29 ->appendArgument(clone $arguments[0])
30 ->appendArgument(clone $arguments[1]);
32 // Include the expiration time, if given.
33 if (sizeof($arguments) == 4) {
34 $set->appendArgument(clone $arguments[3]);