Provide context in ContributionsToolLinks hook
authorKunal Mehta <legoktm@member.fsf.org>
Thu, 4 Aug 2016 21:48:29 +0000 (14:48 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Thu, 4 Aug 2016 21:48:29 +0000 (14:48 -0700)
Most of the hook functions need context to see what the current user's
permissions are, to generate messages, or the LinkRenderer service to
generate the tool links.

Change-Id: I19fa27c8115ee39dded6cb98f29c35b66b934f8a

docs/hooks.txt
includes/specials/SpecialContributions.php
includes/specials/SpecialDeletedContributions.php

index 89a54d5..79cfb47 100644 (file)
@@ -1104,6 +1104,9 @@ $row: the DB row for this line
 $id: User identifier
 $title: User page title
 &$tools: Array of tool links
+$specialPage: SpecialPage instance for context and services. Can be either
+  SpecialContributions or DeletedContributionsPage. Extensions should type
+  hint against a generic SpecialPage though.
 
 'ConvertContent': Called by AbstractContent::convert when a conversion to
 another content model is requested.
index cce88b9..d769cb3 100644 (file)
@@ -392,7 +392,7 @@ class SpecialContributions extends IncludableSpecialPage {
                        );
                }
 
-               Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools ] );
+               Hooks::run( 'ContributionsToolLinks', [ $id, $userpage, &$tools, $this ] );
 
                return $tools;
        }
index 190bf9f..a402d3c 100644 (file)
@@ -219,7 +219,7 @@ class DeletedContributionsPage extends SpecialPage {
                                );
                        }
 
-                       Hooks::run( 'ContributionsToolLinks', [ $id, $nt, &$tools ] );
+                       Hooks::run( 'ContributionsToolLinks', [ $id, $nt, &$tools, $this ] );
 
                        $links = $this->getLanguage()->pipeList( $tools );