Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F72138746
PhabricatorSpacesNamespacePHIDType.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
Sun, Jul 14, 22:33
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jul 16, 22:33 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19038543
Attached To
rPH Phabricator
PhabricatorSpacesNamespacePHIDType.php
View Options
<?php
final
class
PhabricatorSpacesNamespacePHIDType
extends
PhabricatorPHIDType
{
const
TYPECONST
=
'SPCE'
;
public
function
getTypeName
()
{
return
pht
(
'Space'
);
}
public
function
newObject
()
{
return
new
PhabricatorSpacesNamespace
();
}
public
function
getPHIDTypeApplicationClass
()
{
return
'PhabricatorSpacesApplication'
;
}
protected
function
buildQueryForObjects
(
PhabricatorObjectQuery
$query
,
array
$phids
)
{
return
id
(
new
PhabricatorSpacesNamespaceQuery
())
->
withPHIDs
(
$phids
);
}
public
function
loadHandles
(
PhabricatorHandleQuery
$query
,
array
$handles
,
array
$objects
)
{
foreach
(
$handles
as
$phid
=>
$handle
)
{
$namespace
=
$objects
[
$phid
];
$monogram
=
$namespace
->
getMonogram
();
$name
=
$namespace
->
getNamespaceName
();
$handle
->
setName
(
$name
);
$handle
->
setFullName
(
pht
(
'%s %s'
,
$monogram
,
$name
));
$handle
->
setURI
(
'/'
.
$monogram
);
if
(
$namespace
->
getIsArchived
())
{
$handle
->
setStatus
(
PhabricatorObjectHandle
::
STATUS_CLOSED
);
}
}
}
public
function
canLoadNamedObject
(
$name
)
{
return
preg_match
(
'/^S[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
PhabricatorSpacesNamespaceQuery
())
->
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