From 9057196d217ecb1854e62107952275b570ab126a Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 19 Nov 2015 10:06:58 -0800 Subject: [PATCH] Add accessor for bundled events in EventPresentationModel The implementation of this sucks as the presentation model should not be making database queries. But the API it provides is what we want and will be supported even if the backend implementation is changed. Change-Id: Ifd0d11260990fd0e00e8f32eee273f9717d3e1fb --- .../formatters/EventPresentationModel.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/includes/formatters/EventPresentationModel.php b/includes/formatters/EventPresentationModel.php index 2d2f8bb53..2245f73e7 100644 --- a/includes/formatters/EventPresentationModel.php +++ b/includes/formatters/EventPresentationModel.php @@ -80,6 +80,26 @@ abstract class EchoEventPresentationModel { return $msg; } + /** + * @return EchoEvent[] + */ + final protected function getBundledEvents() { + if ( !$this->event->getBundleHash() ) { + return array(); + } + + // FIXME: We really shouldn't be making db queries like this + // in the presentation model + $eventMapper = new EchoEventMapper(); + $events = $eventMapper->fetchByUserBundleHash( + $this->user, + $this->event->getBundleHash() + // default params: web, DESC, limit=250 + ); + + return $events; + } + /** * @return string The symbolic icon name as defined in $wgEchoNotificationIcons */