X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FFixer%2FFormCallbackToMethod.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FFixer%2FFormCallbackToMethod.php;h=a19c2a1273e45eb2a3f0c4f1676e8a0750e7070e;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Fixer/FormCallbackToMethod.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Fixer/FormCallbackToMethod.php new file mode 100644 index 000000000..a19c2a127 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Fixer/FormCallbackToMethod.php @@ -0,0 +1,43 @@ +target + ->getIndexer('function') + ->get($this->configuration['callback']); + + list ($class, $method_name) = explode('::', $this->configuration['destination']); + /** @var \Pharborist\Objects\ClassNode $class */ + $class = $this + ->target + ->getIndexer('class') + ->get($class); + + $method = $callback->cloneAsMethodOf($class)->setName($method_name); + + $form_interface = new \ReflectionClass('\Drupal\Core\Form\FormInterface'); + if ($form_interface->hasMethod($method_name)) { + $method->matchReflector($form_interface->getMethod($method_name)); + } + + $this->target->save($method); + } + +}