Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/provider/PhabricatorJIRAAuthProvider.php
| <?php | <?php | ||||
| final class PhabricatorJIRAAuthProvider extends PhabricatorOAuth1AuthProvider { | final class PhabricatorJIRAAuthProvider | ||||
| extends PhabricatorOAuth1AuthProvider | |||||
| public function getJIRABaseURI() { | implements DoorkeeperRemarkupURIInterface { | ||||
| return $this->getProviderConfig()->getProperty(self::PROPERTY_JIRA_URI); | |||||
| } | |||||
| public function getProviderName() { | public function getProviderName() { | ||||
| return pht('JIRA'); | return pht('JIRA'); | ||||
| } | } | ||||
| public function getDescriptionForCreate() { | public function getDescriptionForCreate() { | ||||
| return pht('Configure JIRA OAuth. NOTE: Only supports JIRA 6.'); | return pht('Configure JIRA OAuth. NOTE: Only supports JIRA 6.'); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | public function shouldCreateJIRALink() { | ||||
| return $config->getProperty(self::PROPERTY_REPORT_LINK, true); | return $config->getProperty(self::PROPERTY_REPORT_LINK, true); | ||||
| } | } | ||||
| public function shouldCreateJIRAComment() { | public function shouldCreateJIRAComment() { | ||||
| $config = $this->getProviderConfig(); | $config = $this->getProviderConfig(); | ||||
| return $config->getProperty(self::PROPERTY_REPORT_COMMENT, true); | return $config->getProperty(self::PROPERTY_REPORT_COMMENT, true); | ||||
| } | } | ||||
| /* -( DoorkeeperRemarkupURIInterface )------------------------------------- */ | |||||
| public function getDoorkeeperURIRef(PhutilURI $uri) { | |||||
| $uri_string = phutil_string_cast($uri); | |||||
| $pattern = '((https?://\S+?)/browse/([A-Z]+-[1-9]\d*))'; | |||||
| $matches = null; | |||||
| if (!preg_match($pattern, $uri_string, $matches)) { | |||||
| return null; | |||||
| } | |||||
| $domain = $matches[1]; | |||||
| $issue = $matches[2]; | |||||
| $config = $this->getProviderConfig(); | |||||
| $base_uri = $config->getProperty(self::PROPERTY_JIRA_URI); | |||||
| if ($domain !== rtrim($base_uri, '/')) { | |||||
| return null; | |||||
| } | |||||
| return id(new DoorkeeperURIRef()) | |||||
| ->setURI($uri) | |||||
| ->setApplicationType(DoorkeeperBridgeJIRA::APPTYPE_JIRA) | |||||
| ->setApplicationDomain($this->getProviderDomain()) | |||||
| ->setObjectType(DoorkeeperBridgeJIRA::OBJTYPE_ISSUE) | |||||
| ->setObjectID($issue); | |||||
| } | |||||
| } | } | ||||