From fbd127fc882ad79669615b5745e71efb8696933c Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 29 Nov 2013 22:20:03 -0800 Subject: [PATCH] Add public setters for EchoEvent attributes So extensions can modify an event, like bug 57234. Change-Id: I60b61d635eb3ab033dc9cc8d8bbf751e2221acc8 --- model/Event.php | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/model/Event.php b/model/Event.php index 9f5a0966c..8f60cfbfc 100644 --- a/model/Event.php +++ b/model/Event.php @@ -112,13 +112,7 @@ class EchoEvent { if ( !$obj->title instanceof Title ) { throw new MWException( 'Invalid title parameter' ); } - $pageId = $obj->title->getArticleId(); - if ( $pageId ) { - $obj->pageId = $pageId; - } else { - $obj->extra['page_title'] = $obj->title->getDBKey(); - $obj->extra['page_namespace'] = $obj->title->getNamespace(); - } + $obj->setTitle( $obj->title ); } if ( $obj->agent && ! @@ -415,6 +409,34 @@ class EchoEvent { return EchoNotificationController::getNotificationCategory( $this->type ); } + public function setType( $type ) { + $this->type = $type; + } + + public function setVariant( $variant ) { + $this->variant = $variant; + } + + public function setAgent( User $agent ) { + $this->agent = $agent; + } + + public function setTitle( Title $title ) { + $this->title = $title; + $pageId = $title->getArticleId(); + if ( $pageId ) { + $this->pageId = $pageId; + } else { + $this->extra['page_title'] = $title->getDBKey(); + $this->extra['page_namespace'] = $title->getNamespace(); + } + + } + + public function setExtra( $name, $value ) { + $this->extra[$name] = $value; + } + /** * Get the message key of the primary or secondary link for a notification type. *