@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<?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 */
7abstract 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(self::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}