Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / CacheSet.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 = "cache_set",
12  *  description = @Translation("Rewrites calls to cache_set().")
13  * )
14  */
15 class CacheSet extends FunctionCallModifier {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function rewrite(FunctionCallNode $call, TargetInterface $target) {
21     $arguments = $call->getArguments();
22
23     $cache = ClassMethodCallNode::create('\Drupal', 'cache');
24     if (sizeof($arguments) > 2) {
25       $cache->appendArgument(clone $arguments[2]);
26     }
27
28     $set = $cache->appendMethodCall('set')
29       ->appendArgument(clone $arguments[0])
30       ->appendArgument(clone $arguments[1]);
31
32     // Include the expiration time, if given.
33     if (sizeof($arguments) == 4) {
34       $set->appendArgument(clone $arguments[3]);
35     }
36
37     return $set;
38   }
39
40 }