Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/celerity/resources/CelerityPhysicalResources.php
12256 views
1
<?php
2
3
/**
4
* Defines the location of physical static resources which exist at build time
5
* and are precomputed into a resource map.
6
*/
7
abstract class CelerityPhysicalResources extends CelerityResources {
8
9
private $map;
10
11
abstract public function getPathToMap();
12
abstract public function findBinaryResources();
13
abstract public function findTextResources();
14
15
public function loadMap() {
16
if ($this->map === null) {
17
$this->map = include $this->getPathToMap();
18
}
19
return $this->map;
20
}
21
22
public static function getAll() {
23
static $resources_map;
24
25
if ($resources_map === null) {
26
$resources_list = id(new PhutilClassMapQuery())
27
->setAncestorClass(__CLASS__)
28
->setUniqueMethod('getName')
29
->execute();
30
31
foreach ($resources_list as $resources) {
32
$name = $resources->getName();
33
34
if (!preg_match('/^[a-z0-9]+/', $name)) {
35
throw new Exception(
36
pht(
37
'Resources name "%s" is not valid; it must contain only '.
38
'lowercase latin letters and digits.',
39
$name));
40
}
41
}
42
43
$resources_map = $resources_list;
44
}
45
46
return $resources_map;
47
}
48
49
}
50
51