Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121791737
PhabricatorRepositoryPHIDTypeRepository.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 13, 22:46
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jul 15, 22:46 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27391833
Attached To
rPH Phabricator
PhabricatorRepositoryPHIDTypeRepository.php
View Options
<?php
final
class
PhabricatorRepositoryPHIDTypeRepository
extends
PhabricatorPHIDType
{
const
TYPECONST
=
'REPO'
;
public
function
getTypeConstant
()
{
return
self
::
TYPECONST
;
}
public
function
getTypeName
()
{
return
pht
(
'Repository'
);
}
public
function
newObject
()
{
return
new
PhabricatorRepository
();
}
protected
function
buildQueryForObjects
(
PhabricatorObjectQuery
$query
,
array
$phids
)
{
return
id
(
new
PhabricatorRepositoryQuery
())
->
withPHIDs
(
$phids
);
}
public
function
loadHandles
(
PhabricatorHandleQuery
$query
,
array
$handles
,
array
$objects
)
{
foreach
(
$handles
as
$phid
=>
$handle
)
{
$repository
=
$objects
[
$phid
];
$callsign
=
$repository
->
getCallsign
();
$name
=
$repository
->
getName
();
$handle
->
setName
(
"r{$callsign}"
);
$handle
->
setFullName
(
"r{$callsign} ({$name})"
);
$handle
->
setURI
(
"/diffusion/{$callsign}/"
);
}
}
public
function
canLoadNamedObject
(
$name
)
{
return
preg_match
(
'/^r[A-Z]+$/'
,
$name
);
}
public
function
loadNamedObjects
(
PhabricatorObjectQuery
$query
,
array
$names
)
{
$id_map
=
array
();
foreach
(
$names
as
$name
)
{
$id
=
substr
(
$name
,
1
);
$id_map
[
$id
][]
=
$name
;
}
$objects
=
id
(
new
PhabricatorRepositoryQuery
())
->
setViewer
(
$query
->
getViewer
())
->
withCallsigns
(
array_keys
(
$id_map
))
->
execute
();
$results
=
array
();
foreach
(
$objects
as
$object
)
{
$callsign
=
$object
->
getCallsign
();
foreach
(
idx
(
$id_map
,
$callsign
,
array
())
as
$name
)
{
$results
[
$name
]
=
$object
;
}
}
return
$results
;
}
}
Event Timeline
Log In to Comment