@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
1<?php
2
3/**
4 * Records information about symbol locations in a codebase, like where classes
5 * and functions are defined.
6 *
7 * Query symbols with @{class:DiffusionSymbolQuery}.
8 */
9final class PhabricatorRepositorySymbol extends PhabricatorRepositoryDAO {
10
11 protected $repositoryPHID;
12 protected $symbolContext;
13 protected $symbolName;
14 protected $symbolType;
15 protected $symbolLanguage;
16 protected $pathID;
17 protected $lineNumber;
18 private $isExternal;
19 private $source;
20 private $location;
21 private $externalURI;
22
23 private $path = self::ATTACHABLE;
24 private $repository = self::ATTACHABLE;
25
26 protected function getConfiguration() {
27 return array(
28 self::CONFIG_TIMESTAMPS => false,
29 self::CONFIG_COLUMN_SCHEMA => array(
30 'id' => null,
31 'symbolContext' => 'text128',
32 'symbolName' => 'text128',
33 'symbolType' => 'text12',
34 'symbolLanguage' => 'text32',
35 'lineNumber' => 'uint32',
36 ),
37 self::CONFIG_KEY_SCHEMA => array(
38 'PRIMARY' => null,
39 'symbolName' => array(
40 'columns' => array('symbolName'),
41 ),
42 ),
43 ) + parent::getConfiguration();
44 }
45
46 public function getURI() {
47 if ($this->isExternal) {
48 return $this->externalURI;
49 }
50
51 $request = DiffusionRequest::newFromDictionary(
52 array(
53 'user' => PhabricatorUser::getOmnipotentUser(),
54 'repository' => $this->getRepository(),
55 ));
56 return $request->generateURI(
57 array(
58 'action' => 'browse',
59 'path' => $this->getPath(),
60 'line' => $this->getLineNumber(),
61 ));
62 }
63
64 public function getPath() {
65 return $this->assertAttached($this->path);
66 }
67
68 public function attachPath($path) {
69 $this->path = $path;
70 return $this;
71 }
72
73 public function getRepository() {
74 return $this->assertAttached($this->repository);
75 }
76
77 public function attachRepository(PhabricatorRepository $repository) {
78 $this->repository = $repository;
79 return $this;
80 }
81
82 public function isExternal() {
83 return $this->isExternal;
84 }
85 public function setIsExternal($is_external) {
86 $this->isExternal = $is_external;
87 return $this;
88 }
89
90 public function getSource() {
91 return $this->source;
92 }
93 public function setSource($source) {
94 $this->source = $source;
95 return $this;
96 }
97
98 public function getLocation() {
99 return $this->location;
100 }
101 public function setLocation($location) {
102 $this->location = $location;
103 return $this;
104 }
105
106 public function setExternalURI($external_uri) {
107 $this->externalURI = $external_uri;
108 return $this;
109 }
110}