[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
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 if ($resources_map === null) { 25 $resources_map = array(); 26 27 $resources_list = id(new PhutilSymbolLoader()) 28 ->setAncestorClass('CelerityPhysicalResources') 29 ->loadObjects(); 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 if (empty($resources_map[$name])) { 43 $resources_map[$name] = $resources; 44 } else { 45 $old = get_class($resources_map[$name]); 46 $new = get_class($resources); 47 throw new Exception( 48 pht( 49 'Celerity resource maps must have unique names, but maps %s and '. 50 '%s share the same name, "%s".', 51 $old, 52 $new, 53 $name)); 54 } 55 } 56 } 57 58 return $resources_map; 59 } 60 61 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |