Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78689685
PholioMockPHIDType.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
Thu, Aug 22, 10:23
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Aug 24, 10:23 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20086471
Attached To
rPH Phabricator
PholioMockPHIDType.php
View Options
<?php
final
class
PholioMockPHIDType
extends
PhabricatorPHIDType
{
const
TYPECONST
=
'MOCK'
;
public
function
getTypeName
()
{
return
pht
(
'Pholio Mock'
);
}
public
function
newObject
()
{
return
new
PholioMock
();
}
public
function
getPHIDTypeApplicationClass
()
{
return
'PhabricatorPholioApplication'
;
}
protected
function
buildQueryForObjects
(
PhabricatorObjectQuery
$query
,
array
$phids
)
{
return
id
(
new
PholioMockQuery
())
->
withPHIDs
(
$phids
);
}
public
function
loadHandles
(
PhabricatorHandleQuery
$query
,
array
$handles
,
array
$objects
)
{
foreach
(
$handles
as
$phid
=>
$handle
)
{
$mock
=
$objects
[
$phid
];
$id
=
$mock
->
getID
();
$name
=
$mock
->
getName
();
$handle
->
setURI
(
"/M{$id}"
);
$handle
->
setName
(
"M{$id}"
);
$handle
->
setFullName
(
"M{$id}: {$name}"
);
if
(
$mock
->
isClosed
())
{
$handle
->
setStatus
(
PhabricatorObjectHandle
::
STATUS_CLOSED
);
}
}
}
public
function
canLoadNamedObject
(
$name
)
{
return
preg_match
(
'/^M
\d
*[1-9]
\d
*$/i'
,
$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
PholioMockQuery
())
->
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