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

Make lookupFileInformation() a private API on CelerityResourceMap

Summary: Ref T4222. Currently, this exposes a bunch of information about the Celerity internals. This information is difficult to preserve exactly with the new maps. Strengthen the API by providing more specific capabilities.

Test Plan: Regenerated map, browsed around.

Reviewers: btrahan, hach-que

Reviewed By: hach-que

CC: aran

Maniphest Tasks: T4222

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

+48 -17
+33 -1
src/infrastructure/celerity/CelerityResourceMap.php
··· 108 108 return idx($this->resourceMap, $symbol); 109 109 } 110 110 111 - public function lookupFileInformation($path) { 111 + private function lookupFileInformation($path) { 112 112 if (empty($this->reverseMap)) { 113 113 $this->reverseMap = array(); 114 114 foreach ($this->resourceMap as $symbol => $data) { ··· 118 118 } 119 119 return idx($this->reverseMap, $path); 120 120 } 121 + 122 + 123 + /** 124 + * Return the fully-qualified, absolute URI for the resource associated with 125 + * a resource name. This method is fairly low-level and ignores packaging. 126 + * 127 + * @param string Resource name to lookup. 128 + * @return string Fully-qualified resource URI. 129 + */ 130 + public function getFullyQualifiedURIForName($name) { 131 + $info = $this->lookupFileInformation($name); 132 + if ($info) { 133 + return idx($info, 'uri'); 134 + } 135 + return null; 136 + } 137 + 138 + 139 + /** 140 + * Return the resource symbols required by a named resource. 141 + * 142 + * @param string Resource name to lookup. 143 + * @return list<string> List of required symbols. 144 + */ 145 + public function getRequiredSymbolsForName($name) { 146 + $info = $this->lookupFileInformation($name); 147 + if ($info) { 148 + return idx($info, 'requires', array()); 149 + } 150 + return null; 151 + } 152 + 121 153 122 154 }
+3 -3
src/infrastructure/celerity/CelerityResourceTransformer.php
··· 127 127 $uri = $this->rawResourceMap[$uri]['uri']; 128 128 } 129 129 } else if ($this->celerityMap) { 130 - $info = $this->celerityMap->lookupFileInformation($uri); 131 - if ($info) { 132 - $uri = $info['uri']; 130 + $resource_uri = $this->celerityMap->getFullyQualifiedURIForName($uri); 131 + if ($resource_uri) { 132 + $uri = $resource_uri; 133 133 } 134 134 } 135 135
+5 -5
src/infrastructure/celerity/api.php
··· 52 52 function celerity_get_resource_uri($resource) { 53 53 $map = CelerityResourceMap::getInstance(); 54 54 55 - $info = $map->lookupFileInformation($resource); 56 - if ($info) { 57 - return $info['uri']; 58 - } else { 59 - return $resource; 55 + $uri = $map->getFullyQualifiedURIForName($resource); 56 + if ($uri) { 57 + return $uri; 60 58 } 59 + 60 + return $resource; 61 61 }
+7 -8
src/infrastructure/lint/linter/PhabricatorJavelinLinter.php
··· 147 147 $path); 148 148 $need = $external_classes; 149 149 150 - $info = $celerity->lookupFileInformation(substr($path, strlen('webroot'))); 151 - if (!$info) { 152 - $info = array(); 150 + $resource_name = substr($path, strlen('webroot')); 151 + $requires = $celerity->getRequiredSymbolsForName($resource_name); 152 + if (!$requires) { 153 + $requires = array(); 153 154 } 154 155 155 - $requires = idx($info, 'requires', array()); 156 - 157 - foreach ($requires as $key => $name) { 158 - $symbol_info = $celerity->lookupSymbolInformation($name); 156 + foreach ($requires as $key => $symbol_name) { 157 + $symbol_info = $celerity->lookupSymbolInformation($symbol_name); 159 158 if (!$symbol_info) { 160 159 $this->raiseLintAtLine( 161 160 0, 162 161 0, 163 162 self::LINT_UNKNOWN_DEPENDENCY, 164 - "This file @requires component '{$name}', but it does not ". 163 + "This file @requires component '{$symbol_name}', but it does not ". 165 164 "exist. You may need to rebuild the Celerity map."); 166 165 unset($requires[$key]); 167 166 continue;