From 23f243a9a6aa9b00f6949d5d1d1a3c09ad7ec366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Such=C3=A1nek?= Date: Thu, 4 Aug 2016 15:19:20 +0000 Subject: [PATCH] Generate sample notifications for Wikibase Bug: T110604 Change-Id: I6e6817f80bbf8a8c28cfa59efdf424f736bb4e33 --- maintenance/generateSampleNotifications.php | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/maintenance/generateSampleNotifications.php b/maintenance/generateSampleNotifications.php index 1d0bbbc62..bd2926b08 100644 --- a/maintenance/generateSampleNotifications.php +++ b/maintenance/generateSampleNotifications.php @@ -23,6 +23,7 @@ class GenerateSampleNotifications extends Maintenance { 'osm', 'edit-thanks', 'edu', + 'page-connection', ); public function __construct() { @@ -121,6 +122,10 @@ class GenerateSampleNotifications extends Maintenance { $this->generateEducationProgram( $user, $agent ); } + if ( $this->shouldGenerate( 'page-connection', $types ) ) { + $this->generateWikibase( $user, $agent ); + } + $this->output( "Completed \n" ); } @@ -466,6 +471,29 @@ class GenerateSampleNotifications extends Maintenance { // NOTE: Not generating 'ep-course-talk-notification' for now // as it requires a full setup to actually work (institution, course, instructors, students). } + + private function generateWikibase( User $user, User $agent ) { + if ( !class_exists( 'Wikibase\Client\Hooks\EchoNotificationsHandlers' ) ) { + $this->output( 'class Wikibase\Client\Hooks\EchoNotificationsHandlers not found' ); + return; + } + + $title = $this->generateNewPageTitle(); + $this->addToPageContent( $title, $user, "this is a new page" ); + $helpPage = Title::newFromText( 'Project:Wikidata' ); + $this->addToPageContent( $helpPage, $user, "this is the help page" ); + + $this->output( "{$agent->getName()} is connecting {$user->getName()}'s page {$title->getPrefixedText()} to an item\n" ); + EchoEvent::create( [ + 'type' => Wikibase\Client\Hooks\EchoNotificationsHandlers::NOTIFICATION_TYPE, + 'title' => $title, + 'extra' => [ + 'url' => Title::newFromText( 'Item:Q1' )->getFullURL(), + 'repoSiteName' => 'Wikidata' + ], + 'agent' => $agent, + ] ); + } } $maintClass = "GenerateSampleNotifications";