@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Minor tidying of `DivinerPublisher` classes

Summary: Self-explanatory. Also made a few methods `final`.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11598

+21 -27
+2 -6
src/applications/diviner/publisher/DivinerLivePublisher.php
··· 8 8 if (!$this->book) { 9 9 $book_name = $this->getConfig('name'); 10 10 11 - $book = id(new DivinerLiveBook())->loadOneWhere( 12 - 'name = %s', 13 - $book_name); 11 + $book = id(new DivinerLiveBook())->loadOneWhere('name = %s', $book_name); 14 12 if (!$book) { 15 13 $book = id(new DivinerLiveBook()) 16 14 ->setName($book_name) ··· 19 17 } 20 18 21 19 $book->setConfigurationData($this->getConfigurationData())->save(); 22 - 23 20 $this->book = $book; 24 21 } 22 + 25 23 return $this->book; 26 24 } 27 25 ··· 75 73 protected function deleteDocumentsByHash(array $hashes) { 76 74 $atom_table = new DivinerLiveAtom(); 77 75 $symbol_table = new DivinerLiveSymbol(); 78 - 79 76 $conn_w = $symbol_table->establishConnection('w'); 80 77 81 78 $strings = array(); ··· 149 146 150 147 public function findAtomByRef(DivinerAtomRef $ref) { 151 148 // TODO: Actually implement this. 152 - 153 149 return null; 154 150 } 155 151
+18 -19
src/applications/diviner/publisher/DivinerPublisher.php
··· 10 10 private $symbolReverseMap; 11 11 private $dropCaches; 12 12 13 - public function setDropCaches($drop_caches) { 13 + public final function setDropCaches($drop_caches) { 14 14 $this->dropCaches = $drop_caches; 15 15 return $this; 16 16 } 17 17 18 - public function setRenderer(DivinerRenderer $renderer) { 18 + public final function setRenderer(DivinerRenderer $renderer) { 19 19 $renderer->setPublisher($this); 20 20 $this->renderer = $renderer; 21 21 return $this; 22 22 } 23 23 24 - public function getRenderer() { 24 + public final function getRenderer() { 25 25 return $this->renderer; 26 26 } 27 27 28 - public function setConfig(array $config) { 28 + public final function setConfig(array $config) { 29 29 $this->config = $config; 30 30 return $this; 31 31 } 32 32 33 - public function getConfig($key, $default = null) { 33 + public final function getConfig($key, $default = null) { 34 34 return idx($this->config, $key, $default); 35 35 } 36 36 37 - public function getConfigurationData() { 37 + public final function getConfigurationData() { 38 38 return $this->config; 39 39 } 40 40 41 - public function setAtomCache(DivinerAtomCache $cache) { 41 + public final function setAtomCache(DivinerAtomCache $cache) { 42 42 $this->atomCache = $cache; 43 43 $graph_map = $this->atomCache->getGraphMap(); 44 44 $this->atomGraphHashToNodeHashMap = array_flip($graph_map); 45 45 return $this; 46 46 } 47 47 48 - protected function getAtomFromGraphHash($graph_hash) { 48 + protected final function getAtomFromGraphHash($graph_hash) { 49 49 if (empty($this->atomGraphHashToNodeHashMap[$graph_hash])) { 50 - throw new Exception("No such atom '{$graph_hash}'!"); 50 + throw new Exception(pht("No such atom '%s'!", $graph_hash)); 51 51 } 52 52 53 53 return $this->getAtomFromNodeHash( 54 54 $this->atomGraphHashToNodeHashMap[$graph_hash]); 55 55 } 56 56 57 - protected function getAtomFromNodeHash($node_hash) { 57 + protected final function getAtomFromNodeHash($node_hash) { 58 58 if (empty($this->atomMap[$node_hash])) { 59 59 $dict = $this->atomCache->getAtom($node_hash); 60 60 $this->atomMap[$node_hash] = DivinerAtom::newFromDictionary($dict); ··· 62 62 return $this->atomMap[$node_hash]; 63 63 } 64 64 65 - protected function getSimilarAtoms(DivinerAtom $atom) { 65 + protected final function getSimilarAtoms(DivinerAtom $atom) { 66 66 if ($this->symbolReverseMap === null) { 67 67 $rmap = array(); 68 68 $smap = $this->atomCache->getSymbolMap(); ··· 75 75 $shash = $atom->getRef()->toHash(); 76 76 77 77 if (empty($this->symbolReverseMap[$shash])) { 78 - throw new Exception('Atom has no symbol map entry!'); 78 + throw new Exception(pht('Atom has no symbol map entry!')); 79 79 } 80 80 81 81 $hashes = $this->symbolReverseMap[$shash]; ··· 91 91 92 92 /** 93 93 * If a book contains multiple definitions of some atom, like some function 94 - * "f()", we assign them an arbitrary (but fairly stable) order and publish 95 - * them as "function/f/1/", "function/f/2/", etc., or similar. 94 + * `f()`, we assign them an arbitrary (but fairly stable) order and publish 95 + * them as `function/f/1/`, `function/f/2/`, etc., or similar. 96 96 */ 97 - protected function getAtomSimilarIndex(DivinerAtom $atom) { 97 + protected final function getAtomSimilarIndex(DivinerAtom $atom) { 98 98 $atoms = $this->getSimilarAtoms($atom); 99 99 if (count($atoms) == 1) { 100 100 return 0; ··· 108 108 $index++; 109 109 } 110 110 111 - throw new Exception('Expected to find atom while disambiguating!'); 111 + throw new Exception(pht('Expected to find atom while disambiguating!')); 112 112 } 113 - 114 113 115 114 abstract protected function loadAllPublishedHashes(); 116 115 abstract protected function deleteDocumentsByHash(array $hashes); 117 116 abstract protected function createDocumentsByHash(array $hashes); 118 117 abstract public function findAtomByRef(DivinerAtomRef $ref); 119 118 120 - final public function publishAtoms(array $hashes) { 119 + public final function publishAtoms(array $hashes) { 121 120 $existing = $this->loadAllPublishedHashes(); 122 121 123 122 if ($this->dropCaches) { ··· 141 140 $this->createDocumentsByHash($created); 142 141 } 143 142 144 - protected function shouldGenerateDocumentForAtom(DivinerAtom $atom) { 143 + protected final function shouldGenerateDocumentForAtom(DivinerAtom $atom) { 145 144 switch ($atom->getType()) { 146 145 case DivinerAtom::TYPE_METHOD: 147 146 case DivinerAtom::TYPE_FILE:
+1 -2
src/applications/diviner/publisher/DivinerStaticPublisher.php
··· 59 59 60 60 protected function createDocumentsByHash(array $hashes) { 61 61 $indexes = array(); 62 - 63 62 $cache = $this->getPublishCache(); 64 63 65 64 foreach ($hashes as $hash) { ··· 89 88 } 90 89 91 90 $this->publishIndex(); 92 - 93 91 $cache->writePathMap(); 94 92 $cache->writeIndex(); 95 93 } ··· 97 95 private function publishIndex() { 98 96 $index = $this->getPublishCache()->getIndex(); 99 97 $refs = array(); 98 + 100 99 foreach ($index as $hash => $dictionary) { 101 100 $refs[$hash] = DivinerAtomRef::newFromDictionary($dictionary); 102 101 }