1 | <?php |
||
23 | class SidebarHookHandler implements |
||
24 | OutputPageParserOutputHook, |
||
25 | SkinTemplateGetLanguageLinkHook, |
||
26 | SidebarBeforeOutputHook |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * @var NamespaceChecker |
||
31 | */ |
||
32 | private $namespaceChecker; |
||
33 | |||
34 | /** |
||
35 | * @var LanguageLinkBadgeDisplay |
||
36 | */ |
||
37 | private $badgeDisplay; |
||
38 | |||
39 | public function __construct( |
||
46 | |||
47 | public static function factory(): self { |
||
48 | $wikibaseClient = WikibaseClient::getDefaultInstance(); |
||
49 | |||
50 | return new self( |
||
51 | $wikibaseClient->getNamespaceChecker(), |
||
52 | $wikibaseClient->getLanguageLinkBadgeDisplay() |
||
53 | ); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Add output page property if repo links are suppressed, and property for item id |
||
58 | * |
||
59 | * @param OutputPage $out |
||
60 | * @param ParserOutput $parserOutput |
||
61 | */ |
||
62 | public function onOutputPageParserOutput( $out, $parserOutput ): void { |
||
93 | |||
94 | /** |
||
95 | * Add badges to the language links. |
||
96 | * |
||
97 | * @param array &$languageLink |
||
98 | * @param Title $languageLinkTitle |
||
99 | * @param Title $title |
||
100 | * @param OutputPage|null $output |
||
101 | */ |
||
102 | public function onSkinTemplateGetLanguageLink( |
||
110 | |||
111 | /** |
||
112 | * SidebarBeforeOutput hook handler |
||
113 | * |
||
114 | * This handler adds too items to the sidebar section. |
||
115 | * First it adds the 'Wikidata items' to the 'toolbox' section of the sidebar. |
||
116 | * Second it adds the 'In other projects' item which lives in its own section. |
||
117 | * |
||
118 | * The items generation logic are handled separately for each. This callback |
||
119 | * is only concerned with adding them to the &$sidebar array (if they exist). |
||
120 | * |
||
121 | * If current page cannot have 'Wikidata item' link, this callback will receive |
||
122 | * null value from ClientHooks::buildWikidataItemLink() method and so it will |
||
123 | * skip attempting to add the link. Same thing repeats for the second case. |
||
124 | * |
||
125 | * @param Skin $skin |
||
126 | * @param array &$sidebar |
||
127 | */ |
||
128 | public function onSidebarBeforeOutput( $skin, &$sidebar ): void { |
||
143 | |||
144 | /** |
||
145 | * Build 'In other projects' section of the sidebar, if enabled project wide or |
||
146 | * the user has the beta featured enabled. |
||
147 | * |
||
148 | * @param Skin $skin |
||
149 | * |
||
150 | * @return null|array[] Array of 'In other projects' contents or null if there are none |
||
151 | */ |
||
152 | public function buildOtherProjectsSidebar( Skin $skin ): ?array { |
||
163 | |||
164 | } |
||
165 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):