Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 61
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
FrontendModulesFactory
0.00% covered (danger)
0.00%
0 / 61
0.00% covered (danger)
0.00%
0 / 6
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
2
 newEventDetailsModule
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
2
 newEventDetailsParticipantsModule
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
2
 newEmailParticipantsModule
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 newResponseStatisticsModule
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
2
 newClickwrapFormModule
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare( strict_types=1 );
4
5namespace MediaWiki\Extension\CampaignEvents\FrontendModules;
6
7use MediaWiki\Extension\CampaignEvents\Event\ExistingEventRegistration;
8use MediaWiki\Extension\CampaignEvents\Hooks\CampaignEventsHookRunner;
9use MediaWiki\Extension\CampaignEvents\Messaging\CampaignsUserMailer;
10use MediaWiki\Extension\CampaignEvents\MWEntity\CampaignsCentralUserLookup;
11use MediaWiki\Extension\CampaignEvents\MWEntity\PageURLResolver;
12use MediaWiki\Extension\CampaignEvents\MWEntity\UserLinker;
13use MediaWiki\Extension\CampaignEvents\MWEntity\WikiLookup;
14use MediaWiki\Extension\CampaignEvents\Organizers\OrganizersStore;
15use MediaWiki\Extension\CampaignEvents\Participants\ParticipantsStore;
16use MediaWiki\Extension\CampaignEvents\Permissions\PermissionChecker;
17use MediaWiki\Extension\CampaignEvents\Questions\EventAggregatedAnswersStore;
18use MediaWiki\Extension\CampaignEvents\Questions\EventQuestionsRegistry;
19use MediaWiki\Extension\CampaignEvents\Questions\ParticipantAnswersStore;
20use MediaWiki\Extension\CampaignEvents\Time\EventTimeFormatter;
21use MediaWiki\Extension\CampaignEvents\TrackingTool\TrackingToolRegistry;
22use MediaWiki\Language\Language;
23use MediaWiki\User\UserFactory;
24use Wikimedia\Message\IMessageFormatterFactory;
25
26class FrontendModulesFactory {
27    public const SERVICE_NAME = 'CampaignEventsFrontendModulesFactory';
28
29    private IMessageFormatterFactory $messageFormatterFactory;
30    private OrganizersStore $organizersStore;
31    private ParticipantsStore $participantsStore;
32    private PageURLResolver $pageURLResolver;
33    private UserLinker $userLinker;
34    private CampaignsCentralUserLookup $centralUserLookup;
35    private PermissionChecker $permissionChecker;
36    private EventTimeFormatter $eventTimeFormatter;
37    private UserFactory $userFactory;
38    private TrackingToolRegistry $trackingToolRegistry;
39    private CampaignsUserMailer $userMailer;
40    private ParticipantAnswersStore $answersStore;
41    private EventAggregatedAnswersStore $aggregatedAnswersStore;
42    private EventQuestionsRegistry $questionsRegistry;
43    private CampaignEventsHookRunner $hookRunner;
44    private WikiLookup $wikiLookup;
45
46    /**
47     * @param IMessageFormatterFactory $messageFormatterFactory
48     * @param OrganizersStore $organizersStore
49     * @param ParticipantsStore $participantsStore
50     * @param PageURLResolver $pageURLResolver
51     * @param UserLinker $userLinker
52     * @param CampaignsCentralUserLookup $centralUserLookup
53     * @param PermissionChecker $permissionChecker
54     * @param EventTimeFormatter $eventTimeFormatter
55     * @param UserFactory $userFactory
56     * @param TrackingToolRegistry $trackingToolRegistry
57     * @param CampaignsUserMailer $userMailer
58     * @param ParticipantAnswersStore $answersStore
59     * @param EventAggregatedAnswersStore $aggregatedAnswersStore
60     * @param EventQuestionsRegistry $questionsRegistry
61     * @param CampaignEventsHookRunner $hookRunner
62     * @param WikiLookup $wikiLookup
63     */
64    public function __construct(
65        IMessageFormatterFactory $messageFormatterFactory,
66        OrganizersStore $organizersStore,
67        ParticipantsStore $participantsStore,
68        PageURLResolver $pageURLResolver,
69        UserLinker $userLinker,
70        CampaignsCentralUserLookup $centralUserLookup,
71        PermissionChecker $permissionChecker,
72        EventTimeFormatter $eventTimeFormatter,
73        UserFactory $userFactory,
74        TrackingToolRegistry $trackingToolRegistry,
75        CampaignsUserMailer $userMailer,
76        ParticipantAnswersStore $answersStore,
77        EventAggregatedAnswersStore $aggregatedAnswersStore,
78        EventQuestionsRegistry $questionsRegistry,
79        CampaignEventsHookRunner $hookRunner,
80        WikiLookup $wikiLookup
81    ) {
82        $this->messageFormatterFactory = $messageFormatterFactory;
83        $this->organizersStore = $organizersStore;
84        $this->participantsStore = $participantsStore;
85        $this->pageURLResolver = $pageURLResolver;
86        $this->userLinker = $userLinker;
87        $this->centralUserLookup = $centralUserLookup;
88        $this->permissionChecker = $permissionChecker;
89        $this->eventTimeFormatter = $eventTimeFormatter;
90        $this->userFactory = $userFactory;
91        $this->trackingToolRegistry = $trackingToolRegistry;
92        $this->userMailer = $userMailer;
93        $this->answersStore = $answersStore;
94        $this->aggregatedAnswersStore = $aggregatedAnswersStore;
95        $this->questionsRegistry = $questionsRegistry;
96        $this->hookRunner = $hookRunner;
97        $this->wikiLookup = $wikiLookup;
98    }
99
100    /**
101     * @param ExistingEventRegistration $registration
102     * @param Language $language
103     * @return EventDetailsModule
104     */
105    public function newEventDetailsModule(
106        ExistingEventRegistration $registration,
107        Language $language
108    ): EventDetailsModule {
109        return new EventDetailsModule(
110            $this->messageFormatterFactory,
111            $this->organizersStore,
112            $this->pageURLResolver,
113            $this->userLinker,
114            $this->eventTimeFormatter,
115            $this->trackingToolRegistry,
116            $this->hookRunner,
117            $this->permissionChecker,
118            $this->wikiLookup,
119            $registration,
120            $language
121        );
122    }
123
124    /**
125     * @param Language $language
126     * @param string $statisticsTabUrl
127     * @return EventDetailsParticipantsModule
128     */
129    public function newEventDetailsParticipantsModule(
130        Language $language,
131        string $statisticsTabUrl
132    ): EventDetailsParticipantsModule {
133        return new EventDetailsParticipantsModule(
134            $this->messageFormatterFactory,
135            $this->userLinker,
136            $this->participantsStore,
137            $this->centralUserLookup,
138            $this->permissionChecker,
139            $this->userFactory,
140            $this->userMailer,
141            $this->questionsRegistry,
142            $language,
143            $statisticsTabUrl
144        );
145    }
146
147    public function newEmailParticipantsModule(): EmailParticipantsModule {
148        return new EmailParticipantsModule(
149            $this->messageFormatterFactory
150        );
151    }
152
153    public function newResponseStatisticsModule(
154        ExistingEventRegistration $event,
155        Language $language
156    ): ResponseStatisticsModule {
157        return new ResponseStatisticsModule(
158            $this->messageFormatterFactory,
159            $this->answersStore,
160            $this->aggregatedAnswersStore,
161            $this->questionsRegistry,
162            $this->participantsStore,
163            $this,
164            $event,
165            $language
166        );
167    }
168
169    /**
170     * @param ExistingEventRegistration $event
171     * @param Language $language
172     * @return ClickwrapFormModule
173     */
174    public function newClickwrapFormModule(
175        ExistingEventRegistration $event,
176        Language $language
177    ): ClickwrapFormModule {
178        return new ClickwrapFormModule(
179            $event,
180            $this->organizersStore,
181            $this->messageFormatterFactory,
182            $language,
183            $this->centralUserLookup
184        );
185    }
186}