Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90512031
PhabricatorFilesOnDiskBuiltinFile.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 2, 08:43
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Nov 4, 08:43 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22090770
Attached To
rPH Phabricator
PhabricatorFilesOnDiskBuiltinFile.php
View Options
<?php
final
class
PhabricatorFilesOnDiskBuiltinFile
extends
PhabricatorFilesBuiltinFile
{
private
$name
;
public
function
setName
(
$name
)
{
$this
->
name
=
$name
;
return
$this
;
}
public
function
getName
()
{
if
(
$this
->
name
===
null
)
{
throw
new
PhutilInvalidStateException
(
'setName'
);
}
return
$this
->
name
;
}
public
function
getBuiltinDisplayName
()
{
return
$this
->
getName
();
}
public
function
getBuiltinFileKey
()
{
$name
=
$this
->
getName
();
$desc
=
"disk(name={$name})"
;
$hash
=
PhabricatorHash
::
digestToLength
(
$desc
,
40
);
return
"builtin:{$hash}"
;
}
public
function
loadBuiltinFileData
()
{
$name
=
$this
->
getName
();
$available
=
$this
->
getAllBuiltinFiles
();
if
(
empty
(
$available
[
$name
]))
{
throw
new
Exception
(
pht
(
'Builtin "%s" does not exist!'
,
$name
));
}
return
Filesystem
::
readFile
(
$available
[
$name
]);
}
private
function
getAllBuiltinFiles
()
{
$root
=
dirname
(
phutil_get_library_root
(
'phabricator'
));
$root
=
$root
.
'/resources/builtin/'
;
$map
=
array
();
$list
=
Filesystem
::
listDirectory
(
$root
,
$include_hidden
=
false
);
foreach
(
$list
as
$file
)
{
$map
[
$file
]
=
$root
.
$file
;
}
return
$map
;
}
}
Event Timeline
Log In to Comment