Path: blob/master/src/applications/doorkeeper/bridge/DoorkeeperBridgeGitHub.php
12256 views
<?php12abstract class DoorkeeperBridgeGitHub extends DoorkeeperBridge {34const APPTYPE_GITHUB = 'github';5const APPDOMAIN_GITHUB = 'github.com';67public function canPullRef(DoorkeeperObjectRef $ref) {8if ($ref->getApplicationType() != self::APPTYPE_GITHUB) {9return false;10}1112if ($ref->getApplicationDomain() != self::APPDOMAIN_GITHUB) {13return false;14}1516return true;17}1819protected function getGitHubAccessToken() {20$context_token = $this->getContextProperty('github.token');21if ($context_token) {22return $context_token->openEnvelope();23}2425// TODO: Do a bunch of work to fetch the viewer's linked account if26// they have one.2728return $this->didFailOnMissingLink();29}3031protected function parseGitHubIssueID($id) {32$matches = null;33if (!preg_match('(^([^/]+)/([^/]+)#([1-9]\d*)\z)', $id, $matches)) {34throw new Exception(35pht(36'GitHub Issue ID "%s" is not properly formatted. Expected an ID '.37'in the form "owner/repository#123".',38$id));39}4041return array(42$matches[1],43$matches[2],44(int)$matches[3],45);46}474849}505152