3 final class PhabricatorFilesOnDiskBuiltinFile
4 extends PhabricatorFilesBuiltinFile
{
8 public function setName($name) {
13 public function getName() {
14 if ($this->name
=== null) {
15 throw new PhutilInvalidStateException('setName');
21 public function getBuiltinDisplayName() {
22 return $this->getName();
25 public function getBuiltinFileKey() {
26 $name = $this->getName();
27 $desc = "disk(name={$name})";
28 $hash = PhabricatorHash
::digestToLength($desc, 40);
29 return "builtin:{$hash}";
32 public function loadBuiltinFileData() {
33 $name = $this->getName();
35 $available = $this->getAllBuiltinFiles();
36 if (empty($available[$name])) {
37 throw new Exception(pht('Builtin "%s" does not exist!', $name));
40 return Filesystem
::readFile($available[$name]);
43 private function getAllBuiltinFiles() {
44 $root = dirname(phutil_get_library_root('phabricator'));
45 $root = $root.'/resources/builtin/';
48 $list = id(new FileFinder($root))
50 ->withFollowSymlinks(true)
53 foreach ($list as $file) {
54 $map[$file] = $root.$file;
59 public function getProjectBuiltinFiles() {
60 $root = dirname(phutil_get_library_root('phabricator'));
61 $root = $root.'/resources/builtin/projects/';
64 $list = id(new FileFinder($root))
66 ->withFollowSymlinks(true)
69 foreach ($list as $file) {
70 $map[$file] = $root.$file;