Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/doorkeeper/bridge/DoorkeeperBridgeGitHub.php
12256 views
1
<?php
2
3
abstract class DoorkeeperBridgeGitHub extends DoorkeeperBridge {
4
5
const APPTYPE_GITHUB = 'github';
6
const APPDOMAIN_GITHUB = 'github.com';
7
8
public function canPullRef(DoorkeeperObjectRef $ref) {
9
if ($ref->getApplicationType() != self::APPTYPE_GITHUB) {
10
return false;
11
}
12
13
if ($ref->getApplicationDomain() != self::APPDOMAIN_GITHUB) {
14
return false;
15
}
16
17
return true;
18
}
19
20
protected function getGitHubAccessToken() {
21
$context_token = $this->getContextProperty('github.token');
22
if ($context_token) {
23
return $context_token->openEnvelope();
24
}
25
26
// TODO: Do a bunch of work to fetch the viewer's linked account if
27
// they have one.
28
29
return $this->didFailOnMissingLink();
30
}
31
32
protected function parseGitHubIssueID($id) {
33
$matches = null;
34
if (!preg_match('(^([^/]+)/([^/]+)#([1-9]\d*)\z)', $id, $matches)) {
35
throw new Exception(
36
pht(
37
'GitHub Issue ID "%s" is not properly formatted. Expected an ID '.
38
'in the form "owner/repository#123".',
39
$id));
40
}
41
42
return array(
43
$matches[1],
44
$matches[2],
45
(int)$matches[3],
46
);
47
}
48
49
50
}
51
52