Page MenuHomeDevCentral

PhabricatorListener.php
No OneTemporary

PhabricatorListener.php

<?php
namespace Nasqueron\Notifications\Listeners;
use Nasqueron\Notifications\Events\GitHubPayloadEvent;
use Nasqueron\Notifications\Jobs\NotifyNewCommitsToDiffusion;
use Illuminate\Events\Dispatcher;
/**
* Listens to events Phabricator is interested by.
*/
class PhabricatorListener {
///
/// GitHub → Phabricator
///
/**
* Handles payload events.
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
public function onGitHubPayload (GitHubPayloadEvent $event) : void {
if ($event->event === 'push') {
$this->notifyNewCommits($event);
}
}
/**
* Notifies Phabricator there are new commits to pull.
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
public function notifyNewCommits (GitHubPayloadEvent $event) : void {
$job = new NotifyNewCommitsToDiffusion(
$event->door,
$event->payload->repository->clone_url
);
$job->handle();
}
///
/// Events listening
///
/**
* Registers the listeners for the subscriber.
*
* @param Dispatcher $events
*/
public function subscribe (Dispatcher $events) : void {
$class = PhabricatorListener::class;
$events->listen(
GitHubPayloadEvent::class,
"$class@onGitHubPayload"
);
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Jul 27, 20:34 (3 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2760764
Default Alt Text
PhabricatorListener.php (1 KB)

Event Timeline