mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 10:52:41 +01:00
4081579e79
Summary: Publish feed stories, including from Pholio. Actual stories are somewhat garbage but it's all display-time; I'm going to do a pass on feed in general. Test Plan: {F26832} Reviewers: btrahan, chad, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T2104 Differential Revision: https://secure.phabricator.com/D4140
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?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 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. Given:
|
|
*
|
|
* phid_group_by_type([PHID-USER-1, PHID-USER-2, PHID-PROJ-3])
|
|
*
|
|
* phid_group_by_type would return:
|
|
*
|
|
* [PhabricatorPHIDConstants::PHID_TYPE_USER => [PHID-USER-1, PHID-USER-2],
|
|
* PhabricatorPHIDConstants::PHID_TYPE_PROJ => [PHID-PROJ-3]]
|
|
*
|
|
* @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;
|
|
}
|