Differential D20538 Diff 48982 src/applications/meta/engineextension/PhabricatorSelfHyperlinkEngineExtension.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/meta/engineextension/PhabricatorSelfHyperlinkEngineExtension.php
| <?php | <?php | ||||
| final class PhabricatorSelfHyperlinkEngineExtension | final class PhabricatorSelfHyperlinkEngineExtension | ||||
| extends PhutilRemarkupHyperlinkEngineExtension { | extends PhabricatorRemarkupHyperlinkEngineExtension { | ||||
| const LINKENGINEKEY = 'phabricator-self'; | const LINKENGINEKEY = 'phabricator-self'; | ||||
| public function processHyperlinks(array $hyperlinks) { | public function processHyperlinks(array $hyperlinks) { | ||||
| $engine = $this->getEngine(); | $engine = $this->getEngine(); | ||||
| $viewer = $engine->getConfig('viewer'); | $viewer = $engine->getConfig('viewer'); | ||||
| // If we don't have a valid viewer, just bail out. We aren't going to be | // If we don't have a valid viewer, just bail out. We aren't going to be | ||||
| // able to do very much. | // able to do very much. | ||||
| if (!$viewer) { | if (!$viewer) { | ||||
| return; | return; | ||||
| } | } | ||||
| // Find links which point to resources on the Phabricator install itself. | $self_links = $this->getSelfLinks($hyperlinks); | ||||
| // We're going to try to enhance these. | |||||
| $self_links = array(); | |||||
| foreach ($hyperlinks as $link) { | |||||
| $uri = $link->getURI(); | |||||
| if (PhabricatorEnv::isSelfURI($uri)) { | |||||
| $self_links[] = $link; | |||||
| } | |||||
| } | |||||
epriestley: I pulled this piece of logic ("find all the URIs which point to this install [with an… | |||||
| // For links in the form "/X123", we can reasonably guess that they are | // For links in the form "/X123", we can reasonably guess that they are | ||||
| // fairly likely to be object names. Try to look them up. | // fairly likely to be object names. Try to look them up. | ||||
| $object_names = array(); | $object_names = array(); | ||||
| foreach ($self_links as $key => $link) { | foreach ($self_links as $key => $link) { | ||||
| $uri = new PhutilURI($link->getURI()); | $uri = new PhutilURI($link->getURI()); | ||||
| $matches = null; | $matches = null; | ||||
| ▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines | |||||
I pulled this piece of logic ("find all the URIs which point to this install [with an HTTP/HTTPS protocol]") up into a parent class.