mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 07:20:57 +01:00
Make lookupSymbolInformation() a private API on CelerityResourceMap
Summary: Ref T4222. Same deal as D7867, but for this other super nebulous "return a blob of stuff" method. Test Plan: Regenerated map, browsed around, etc. Reviewers: btrahan, hach-que Reviewed By: hach-que CC: aran Maniphest Tasks: T4222 Differential Revision: https://secure.phabricator.com/D7868
This commit is contained in:
parent
8aaf5084e8
commit
60ff29ed06
4 changed files with 64 additions and 14 deletions
|
@ -30,14 +30,15 @@ final class PhameBasicTemplateBlogSkin extends PhameBasicBlogSkin {
|
|||
}
|
||||
|
||||
$map = CelerityResourceMap::getInstance();
|
||||
$symbol_info = $map->lookupSymbolInformation('syntax-highlighting-css');
|
||||
$resource_symbol = 'syntax-highlighting-css';
|
||||
$resource_uri = $map->getFullyQualifiedURIForSymbol($resource_symbol);
|
||||
|
||||
$this->cssResources[] = phutil_tag(
|
||||
'link',
|
||||
array(
|
||||
'rel' => 'stylesheet',
|
||||
'type' => 'text/css',
|
||||
'href' => PhabricatorEnv::getCDNURI($symbol_info['uri']),
|
||||
'href' => $resource_uri,
|
||||
));
|
||||
|
||||
$this->cssResources = phutil_implode_html("\n", $this->cssResources);
|
||||
|
|
|
@ -104,7 +104,7 @@ final class CelerityResourceMap {
|
|||
return $paths;
|
||||
}
|
||||
|
||||
public function lookupSymbolInformation($symbol) {
|
||||
private function lookupSymbolInformation($symbol) {
|
||||
return idx($this->resourceMap, $symbol);
|
||||
}
|
||||
|
||||
|
@ -120,12 +120,46 @@ final class CelerityResourceMap {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the epoch timestamp of the last modification time of a symbol.
|
||||
*
|
||||
* @param string Resource symbol to lookup.
|
||||
* @return int Epoch timestamp of last resource modification.
|
||||
*/
|
||||
public function getModifiedTimeForSymbol($symbol) {
|
||||
$info = $this->lookupSymbolInformation($symbol);
|
||||
if ($info) {
|
||||
$root = dirname(phutil_get_library_root('phabricator')).'/webroot';
|
||||
return (int)filemtime($root.$info['disk']);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the fully-qualified, absolute URI for the resource associated with
|
||||
* a symbol. This method is fairly low-level and ignores packaging.
|
||||
*
|
||||
* @param string Resource symbol to lookup.
|
||||
* @return string|null Fully-qualified resource URI, or null if the symbol
|
||||
* is unknown.
|
||||
*/
|
||||
public function getFullyQualifiedURIForSymbol($symbol) {
|
||||
$info = $this->lookupSymbolInformation($symbol);
|
||||
if ($info) {
|
||||
return idx($info, 'uri');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the fully-qualified, absolute URI for the resource associated with
|
||||
* a resource name. This method is fairly low-level and ignores packaging.
|
||||
*
|
||||
* @param string Resource name to lookup.
|
||||
* @return string Fully-qualified resource URI.
|
||||
* @return string|null Fully-qualified resource URI, or null if the name
|
||||
* is unknown.
|
||||
*/
|
||||
public function getFullyQualifiedURIForName($name) {
|
||||
$info = $this->lookupFileInformation($name);
|
||||
|
@ -140,7 +174,8 @@ final class CelerityResourceMap {
|
|||
* Return the resource symbols required by a named resource.
|
||||
*
|
||||
* @param string Resource name to lookup.
|
||||
* @return list<string> List of required symbols.
|
||||
* @return list<string>|null List of required symbols, or null if the name
|
||||
* is unknown.
|
||||
*/
|
||||
public function getRequiredSymbolsForName($name) {
|
||||
$info = $this->lookupFileInformation($name);
|
||||
|
@ -151,4 +186,19 @@ final class CelerityResourceMap {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the resource name for a given symbol.
|
||||
*
|
||||
* @param string Resource symbol to lookup.
|
||||
* @return string|null Resource name, or null if the symbol is unknown.
|
||||
*/
|
||||
public function getResourceNameForSymbol($symbol) {
|
||||
$info = $this->lookupSymbolInformation($symbol);
|
||||
if ($info) {
|
||||
return idx($info, 'disk');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -249,8 +249,7 @@ final class CelerityStaticResourceResponse {
|
|||
$mtime = 0;
|
||||
foreach ($resource['symbols'] as $symbol) {
|
||||
$map = CelerityResourceMap::getInstance();
|
||||
$symbol_info = $map->lookupSymbolInformation($symbol);
|
||||
$mtime = max($mtime, (int)filemtime($root.$symbol_info['disk']));
|
||||
$mtime = max($mtime, $map->getModifiedTimeForSymbol($symbol));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,24 +153,24 @@ final class PhabricatorJavelinLinter extends ArcanistLinter {
|
|||
$requires = array();
|
||||
}
|
||||
|
||||
foreach ($requires as $key => $symbol_name) {
|
||||
$symbol_info = $celerity->lookupSymbolInformation($symbol_name);
|
||||
if (!$symbol_info) {
|
||||
foreach ($requires as $key => $requires_symbol) {
|
||||
$requires_name = $celerity->getResourceNameForSymbol($requires_symbol);
|
||||
if ($requires_name === null) {
|
||||
$this->raiseLintAtLine(
|
||||
0,
|
||||
0,
|
||||
self::LINT_UNKNOWN_DEPENDENCY,
|
||||
"This file @requires component '{$symbol_name}', but it does not ".
|
||||
"exist. You may need to rebuild the Celerity map.");
|
||||
"This file @requires component '{$requires_symbol}', but it does ".
|
||||
"not exist. You may need to rebuild the Celerity map.");
|
||||
unset($requires[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('/\\.css$/', $symbol_info['disk'])) {
|
||||
if (preg_match('/\\.css$/', $requires_name)) {
|
||||
// If JS requires CSS, just assume everything is fine.
|
||||
unset($requires[$key]);
|
||||
} else {
|
||||
$symbol_path = 'webroot'.$symbol_info['disk'];
|
||||
$symbol_path = 'webroot'.$requires_name;
|
||||
list($ignored, $req_install) = $this->getUsedAndInstalledSymbolsForPath(
|
||||
$symbol_path);
|
||||
if (array_intersect_key($req_install, $external_classes)) {
|
||||
|
|
Loading…
Reference in a new issue