Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Plugin / DMU / Converter / Functions / FieldInfoFieldTypes.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 = "field_info_field_types",
12  *  description = @Translation("Rewrites calls to field_info_field_types().")
13  * )
14  */
15 class FieldInfoFieldTypes extends FunctionCallModifier {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function rewrite(FunctionCallNode $call, TargetInterface $target) {
21     $replacement = ClassMethodCallNode::create('\Drupal', 'service')
22       ->appendArgument('plugin.manager.field.field_type');
23
24     $arguments = $call->getArguments();
25     if ($arguments->isEmpty()) {
26       return $replacement->appendMethodCall('getDefinitions');
27     }
28     elseif (sizeof($arguments) == 1) {
29       return $replacement
30         ->appendMethodCall('getDefinition')
31         ->appendArgument(clone $arguments[0]);
32     }
33   }
34
35 }