Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F72321705
PhabricatorFileFilePHIDType.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
Mon, Jul 15, 08:39
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Jul 17, 08:39 (2 d)
Engine
blob
Format
Raw Data
Handle
19039005
Attached To
rPH Phabricator
PhabricatorFileFilePHIDType.php
View Options
<?php
final
class
PhabricatorFileFilePHIDType
extends
PhabricatorPHIDType
{
const
TYPECONST
=
'FILE'
;
public
function
getTypeName
()
{
return
pht
(
'File'
);
}
public
function
newObject
()
{
return
new
PhabricatorFile
();
}
public
function
getPHIDTypeApplicationClass
()
{
return
'PhabricatorFilesApplication'
;
}
protected
function
buildQueryForObjects
(
PhabricatorObjectQuery
$query
,
array
$phids
)
{
return
id
(
new
PhabricatorFileQuery
())
->
withPHIDs
(
$phids
);
}
public
function
loadHandles
(
PhabricatorHandleQuery
$query
,
array
$handles
,
array
$objects
)
{
foreach
(
$handles
as
$phid
=>
$handle
)
{
$file
=
$objects
[
$phid
];
$id
=
$file
->
getID
();
$name
=
$file
->
getName
();
$uri
=
$file
->
getInfoURI
();
$handle
->
setName
(
"F{$id}"
);
$handle
->
setFullName
(
"F{$id}: {$name}"
);
$handle
->
setURI
(
$uri
);
}
}
public
function
canLoadNamedObject
(
$name
)
{
return
preg_match
(
'/^F
\d
*[1-9]
\d
*$/'
,
$name
);
}
public
function
loadNamedObjects
(
PhabricatorObjectQuery
$query
,
array
$names
)
{
$id_map
=
array
();
foreach
(
$names
as
$name
)
{
$id
=
(
int
)
substr
(
$name
,
1
);
$id_map
[
$id
][]
=
$name
;
}
$objects
=
id
(
new
PhabricatorFileQuery
())
->
setViewer
(
$query
->
getViewer
())
->
withIDs
(
array_keys
(
$id_map
))
->
execute
();
$results
=
array
();
foreach
(
$objects
as
$id
=>
$object
)
{
foreach
(
idx
(
$id_map
,
$id
,
array
())
as
$name
)
{
$results
[
$name
]
=
$object
;
}
}
return
$results
;
}
}
Event Timeline
Log In to Comment