Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
EventDetailsHandler
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCampaignEventsGetEventDetails
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2
3declare( strict_types=1 );
4
5namespace MediaWiki\Extension\WikimediaCampaignEvents\Hooks\Handlers;
6
7use MediaWiki\Extension\CampaignEvents\FrontendModules\EventDetailsModule;
8use MediaWiki\Extension\CampaignEvents\Hooks\CampaignEventsGetEventDetailsHook;
9use MediaWiki\Extension\WikimediaCampaignEvents\Grants\GrantsStore;
10use MediaWiki\Output\OutputPage;
11use OOUI\Tag;
12
13class EventDetailsHandler implements CampaignEventsGetEventDetailsHook {
14    private GrantsStore $grantsStore;
15
16    public function __construct(
17        GrantsStore $grantsStore
18    ) {
19        $this->grantsStore = $grantsStore;
20    }
21
22    /**
23     * @inheritDoc
24     */
25    public function onCampaignEventsGetEventDetails(
26        Tag $infoColumn,
27        Tag $organizersColumn,
28        int $eventID,
29        bool $isOrganizer,
30        OutputPage $outputPage,
31        bool $isLocalWiki
32    ): void {
33        if ( !$isOrganizer || !$isLocalWiki ) {
34            return;
35        }
36        $grantID = $this->grantsStore->getGrantID( $eventID );
37        if ( $grantID ) {
38            $outputPage->addModuleStyles( 'oojs-ui.styles.icons-editing-advanced' );
39
40            $grantIDElement = EventDetailsModule::makeSection(
41                'templateAdd',
42                $grantID,
43                $outputPage->msg( 'wikimediacampaignevents-grant-id-event-details-label' )->text()
44            );
45
46            $organizersColumn->appendContent( $grantIDElement );
47        }
48    }
49}