Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / document / DiffusionDocumentRenderingEngine.php
blob800d195726b4a09ac09a8c569a7241bb1a593f45
1 <?php
3 final class DiffusionDocumentRenderingEngine
4 extends PhabricatorDocumentRenderingEngine {
6 private $diffusionRequest;
8 public function setDiffusionRequest(DiffusionRequest $drequest) {
9 $this->diffusionRequest = $drequest;
10 return $this;
13 public function getDiffusionRequest() {
14 return $this->diffusionRequest;
17 protected function newRefViewURI(
18 PhabricatorDocumentRef $ref,
19 PhabricatorDocumentEngine $engine) {
21 $file = $ref->getFile();
22 $engine_key = $engine->getDocumentEngineKey();
23 $drequest = $this->getDiffusionRequest();
25 return (string)$drequest->generateURI(
26 array(
27 'action' => 'browse',
28 'stable' => true,
29 'params' => array(
30 'as' => $engine_key,
32 ));
35 protected function newRefRenderURI(
36 PhabricatorDocumentRef $ref,
37 PhabricatorDocumentEngine $engine) {
39 $engine_key = $engine->getDocumentEngineKey();
41 $file = $ref->getFile();
42 $file_phid = $file->getPHID();
44 $drequest = $this->getDiffusionRequest();
46 return (string)$drequest->generateURI(
47 array(
48 'action' => 'document',
49 'stable' => true,
50 'params' => array(
51 'as' => $engine_key,
52 'filePHID' => $file_phid,
54 ));
57 protected function getSelectedDocumentEngineKey() {
58 return $this->getRequest()->getStr('as');
61 protected function getSelectedLineRange() {
62 $range = $this->getDiffusionRequest()->getLine();
63 return AphrontRequest::parseURILineRange($range, 1000);
66 protected function addApplicationCrumbs(
67 PHUICrumbsView $crumbs,
68 PhabricatorDocumentRef $ref = null) {
69 return;
72 protected function willStageRef(PhabricatorDocumentRef $ref) {
73 $drequest = $this->getDiffusionRequest();
75 $blame_uri = (string)$drequest->generateURI(
76 array(
77 'action' => 'blame',
78 'stable' => true,
79 ));
81 $ref->setBlameURI($blame_uri);
84 protected function willRenderRef(PhabricatorDocumentRef $ref) {
85 $drequest = $this->getDiffusionRequest();
87 $ref->setSymbolMetadata($this->getSymbolMetadata());
89 $coverage = $drequest->loadCoverage();
90 if (strlen($coverage)) {
91 $ref->addCoverage($coverage);
95 private function getSymbolMetadata() {
96 $drequest = $this->getDiffusionRequest();
98 $repo = $drequest->getRepository();
99 $symbol_repos = nonempty($repo->getSymbolSources(), array());
100 $symbol_repos[] = $repo->getPHID();
102 $lang = last(explode('.', $drequest->getPath()));
104 return array(
105 'repositories' => $symbol_repos,
106 'lang' => $lang,
107 'path' => $drequest->getPath(),