Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18921284
utils.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
884 B
Referenced Files
None
Subscribers
None
utils.php
View Options
<?php
/**
* Look up the type of a PHID. Returns
* PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN if it fails to look up the type
*
* @param phid Anything.
* @return string A value from PhabricatorPHIDConstants (ideally)
*/
function
phid_get_type
(
$phid
)
{
$matches
=
null
;
if
(
is_string
(
$phid
)
&&
preg_match
(
'/^PHID-([^-]{4})-/'
,
$phid
,
$matches
))
{
return
$matches
[
1
];
}
return
PhabricatorPHIDConstants
::
PHID_TYPE_UNKNOWN
;
}
/**
* Group a list of phids by type.
*
* @param phids array of phids
* @return map of phid type => list of phids
*/
function
phid_group_by_type
(
$phids
)
{
$result
=
array
();
foreach
(
$phids
as
$phid
)
{
$type
=
phid_get_type
(
$phid
);
$result
[
$type
][]
=
$phid
;
}
return
$result
;
}
function
phid_get_subtype
(
$phid
)
{
if
(
isset
(
$phid
[
14
])
&&
(
$phid
[
14
]
==
'-'
))
{
return
substr
(
$phid
,
10
,
4
);
}
return
null
;
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Nov 11, 1:57 PM (1 d, 19 h)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8240069
Default Alt Text
utils.php (884 B)
Attached To
Mode
rP Phabricator
Attached
Detach File
Event Timeline
Log In to Comment