Generate sample notifications for Wikibase

Bug: T110604
Change-Id: I6e6817f80bbf8a8c28cfa59efdf424f736bb4e33
This commit is contained in:
Matěj Suchánek 2016-08-04 15:19:20 +00:00
parent 61e9957a95
commit 23f243a9a6

View file

@ -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";