Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/celerity/resources/CelerityResources.php
<?php | <?php | ||||
/** | /** | ||||
* Defines the location of static resources. | * Defines the location of static resources. | ||||
*/ | */ | ||||
abstract class CelerityResources { | abstract class CelerityResources { | ||||
private $map; | |||||
abstract public function getName(); | abstract public function getName(); | ||||
abstract public function getPathToMap(); | abstract public function getPathToMap(); | ||||
abstract public function getResourceData($name); | abstract public function getResourceData($name); | ||||
abstract public function findBinaryResources(); | abstract public function findBinaryResources(); | ||||
abstract public function findTextResources(); | abstract public function findTextResources(); | ||||
abstract public function getResourceModifiedTime($name); | |||||
public function getCelerityHash($data) { | public function getCelerityHash($data) { | ||||
$tail = PhabricatorEnv::getEnvConfig('celerity.resource-hash'); | $tail = PhabricatorEnv::getEnvConfig('celerity.resource-hash'); | ||||
$hash = PhabricatorHash::digest($data, $tail); | $hash = PhabricatorHash::digest($data, $tail); | ||||
return substr($hash, 0, 8); | return substr($hash, 0, 8); | ||||
} | } | ||||
public function getResourceType($path) { | public function getResourceType($path) { | ||||
return CelerityResourceTransformer::getResourceType($path); | return CelerityResourceTransformer::getResourceType($path); | ||||
} | } | ||||
public function getResourceURI($hash, $name) { | public function getResourceURI($hash, $name) { | ||||
return "/res/{$hash}/{$name}"; | return "/res/{$hash}/{$name}"; | ||||
} | } | ||||
public function getResourcePackages() { | |||||
return array(); | |||||
} | |||||
public function loadMap() { | |||||
if ($this->map === null) { | |||||
$this->map = include $this->getPathToMap(); | |||||
} | |||||
return $this->map; | |||||
} | |||||
public static function getAll() { | public static function getAll() { | ||||
static $resources_map; | static $resources_map; | ||||
if ($resources_map === null) { | if ($resources_map === null) { | ||||
$resources_map = array(); | $resources_map = array(); | ||||
$resources_list = id(new PhutilSymbolLoader()) | $resources_list = id(new PhutilSymbolLoader()) | ||||
->setAncestorClass('CelerityResources') | ->setAncestorClass('CelerityResources') | ||||
->loadObjects(); | ->loadObjects(); | ||||
Show All 23 Lines |