Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
2.7 kB · 111 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112<?php
final class DiffusionDocumentRenderingEngine extends PhabricatorDocumentRenderingEngine {
private $diffusionRequest;
public function setDiffusionRequest(DiffusionRequest $drequest) { $this->diffusionRequest = $drequest; return $this; }
public function getDiffusionRequest() { return $this->diffusionRequest; }
protected function newRefViewURI( PhabricatorDocumentRef $ref, PhabricatorDocumentEngine $engine) {
$file = $ref->getFile(); $engine_key = $engine->getDocumentEngineKey(); $drequest = $this->getDiffusionRequest();
return (string)$drequest->generateURI( array( 'action' => 'browse', 'stable' => true, 'params' => array( 'as' => $engine_key, ), )); }
protected function newRefRenderURI( PhabricatorDocumentRef $ref, PhabricatorDocumentEngine $engine) {
$engine_key = $engine->getDocumentEngineKey();
$file = $ref->getFile(); $file_phid = $file->getPHID();
$drequest = $this->getDiffusionRequest();
return (string)$drequest->generateURI( array( 'action' => 'document', 'stable' => true, 'params' => array( 'as' => $engine_key, 'filePHID' => $file_phid, ), )); }
protected function getSelectedDocumentEngineKey() { return $this->getRequest()->getStr('as'); }
protected function getSelectedLineRange() { $range = $this->getDiffusionRequest()->getLine(); return AphrontRequest::parseURILineRange($range, 1000); }
protected function addApplicationCrumbs( PHUICrumbsView $crumbs, ?PhabricatorDocumentRef $ref = null) { return; }
protected function willStageRef(PhabricatorDocumentRef $ref) { $drequest = $this->getDiffusionRequest();
$blame_uri = (string)$drequest->generateURI( array( 'action' => 'blame', 'stable' => true, ));
$ref->setBlameURI($blame_uri); }
protected function willRenderRef(PhabricatorDocumentRef $ref) { $drequest = $this->getDiffusionRequest();
$ref->setSymbolMetadata($this->getSymbolMetadata());
$coverage = $drequest->loadCoverage(); if (phutil_nonempty_string($coverage)) { $ref->addCoverage($coverage); } }
private function getSymbolMetadata() { $drequest = $this->getDiffusionRequest();
$repo = $drequest->getRepository(); $symbol_repos = nonempty($repo->getSymbolSources(), array()); $symbol_repos[] = $repo->getPHID();
$lang = last(explode('.', $drequest->getPath()));
return array( 'repositories' => $symbol_repos, 'lang' => $lang, 'path' => $drequest->getPath(), ); }
}