Path: blob/master/src/applications/files/builtin/PhabricatorFilesOnDiskBuiltinFile.php
12242 views
<?php12final class PhabricatorFilesOnDiskBuiltinFile3extends PhabricatorFilesBuiltinFile {45private $name;67public function setName($name) {8$this->name = $name;9return $this;10}1112public function getName() {13if ($this->name === null) {14throw new PhutilInvalidStateException('setName');15}1617return $this->name;18}1920public function getBuiltinDisplayName() {21return $this->getName();22}2324public function getBuiltinFileKey() {25$name = $this->getName();26$desc = "disk(name={$name})";27$hash = PhabricatorHash::digestToLength($desc, 40);28return "builtin:{$hash}";29}3031public function loadBuiltinFileData() {32$name = $this->getName();3334$available = $this->getAllBuiltinFiles();35if (empty($available[$name])) {36throw new Exception(pht('Builtin "%s" does not exist!', $name));37}3839return Filesystem::readFile($available[$name]);40}4142private function getAllBuiltinFiles() {43$root = dirname(phutil_get_library_root('phabricator'));44$root = $root.'/resources/builtin/';4546$map = array();47$list = id(new FileFinder($root))48->withType('f')49->withFollowSymlinks(true)50->find();5152foreach ($list as $file) {53$map[$file] = $root.$file;54}55return $map;56}5758public function getProjectBuiltinFiles() {59$root = dirname(phutil_get_library_root('phabricator'));60$root = $root.'/resources/builtin/projects/';6162$map = array();63$list = id(new FileFinder($root))64->withType('f')65->withFollowSymlinks(true)66->find();6768foreach ($list as $file) {69$map[$file] = $root.$file;70}71return $map;72}7374}757677