X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FConverter%2FHookUserLogin.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FConverter%2FHookUserLogin.php;h=70c47826b0fafabe6ade848ed6765dca5620e676;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/HookUserLogin.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/HookUserLogin.php new file mode 100644 index 000000000..70c47826b --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/HookUserLogin.php @@ -0,0 +1,66 @@ +rewriters = $rewriters; + } + + /** + * {@inheritdoc} + */ + public function convert(TargetInterface $target) { + /** @var \Pharborist\Functions\FunctionDeclarationNode $function */ + $function = $target->getIndexer('function')->get('hook_user_login'); + // The $edit parameter is defunct in Drupal 8, but we'll leave it in + // there as an empty array to prevent errors, and move it to the back + // of the line. + /** @var \Pharborist\Functions\ParameterNode $edit */ + $edit = $function->getParameterList()->shift()->setReference(FALSE)->setValue(ArrayNode::create([])); + $function->appendParameter($edit); + + // Slap a FIXME on the hook implementation, informing the developer that + // $edit and $category are dead. + $comment = $function->getDocComment(); + $comment_text = $comment ? $comment->getCommentText() : ''; + if ($comment_text) { + $comment_text .= "\n\n"; + } + $comment_text .= <<<'END' +@FIXME +The $edit parameter is gone in Drupal 8. It has been left here in order to +prevent 'undefined variable' errors, but it will never actually be passed to +this hook. You'll need to modify this function and remove every reference to it. +END; + $function->setDocComment(DocCommentNode::create($comment_text)); + + $rewriter = $this->rewriters->createInstance('_rewriter:user'); + $this->rewriteFunction($rewriter, $function->getParameterAtIndex(0), $target); + $target->save($function); + } + +}