Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/typeahead/PhabricatorProjectDatasource.php
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | if ($must_have_cols) { | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withProjectPHIDs(array_keys($projs)) | ->withProjectPHIDs(array_keys($projs)) | ||||
->execute(); | ->execute(); | ||||
$has_cols = mgroup($columns, 'getProjectPHID'); | $has_cols = mgroup($columns, 'getProjectPHID'); | ||||
} else { | } else { | ||||
$has_cols = array_fill_keys(array_keys($projs), true); | $has_cols = array_fill_keys(array_keys($projs), true); | ||||
} | } | ||||
if ($projs) { | |||||
// TODO: This is a little ad-hoc, but we don't currently have | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
// infrastructure for bulk querying custom fields efficiently. | |||||
$table = new PhabricatorProjectCustomFieldStorage(); | |||||
$descriptions = $table->loadAllWhere( | |||||
'objectPHID IN (%Ls) AND fieldIndex = %s', | |||||
array_keys($projs), | |||||
PhabricatorHash::digestForIndex('std:project:internal:description')); | |||||
$descriptions = mpull($descriptions, 'getFieldValue', 'getObjectPHID'); | |||||
} else { | |||||
$descriptions = array(); | |||||
} | |||||
$results = array(); | $results = array(); | ||||
foreach ($projs as $proj) { | foreach ($projs as $proj) { | ||||
if (!isset($has_cols[$proj->getPHID()])) { | $phid = $proj->getPHID(); | ||||
if (!isset($has_cols[$phid])) { | |||||
continue; | continue; | ||||
} | } | ||||
$slug = $proj->getPrimarySlug(); | $slug = $proj->getPrimarySlug(); | ||||
if (!strlen($slug)) { | if (!strlen($slug)) { | ||||
foreach ($proj->getSlugs() as $slug_object) { | foreach ($proj->getSlugs() as $slug_object) { | ||||
$slug = $slug_object->getSlug(); | $slug = $slug_object->getSlug(); | ||||
if (strlen($slug)) { | if (strlen($slug)) { | ||||
Show All 25 Lines | foreach ($projs as $proj) { | ||||
} | } | ||||
$all_strings = implode(' ', $all_strings); | $all_strings = implode(' ', $all_strings); | ||||
$proj_result = id(new PhabricatorTypeaheadResult()) | $proj_result = id(new PhabricatorTypeaheadResult()) | ||||
->setName($all_strings) | ->setName($all_strings) | ||||
->setDisplayName($proj->getDisplayName()) | ->setDisplayName($proj->getDisplayName()) | ||||
->setDisplayType($proj->getDisplayIconName()) | ->setDisplayType($proj->getDisplayIconName()) | ||||
->setURI($proj->getURI()) | ->setURI($proj->getURI()) | ||||
->setPHID($proj->getPHID()) | ->setPHID($phid) | ||||
->setIcon($proj->getDisplayIconIcon()) | ->setIcon($proj->getDisplayIconIcon()) | ||||
->setColor($proj->getColor()) | ->setColor($proj->getColor()) | ||||
->setPriorityType('proj') | ->setPriorityType('proj') | ||||
->setClosed($closed); | ->setClosed($closed); | ||||
if (strlen($slug)) { | if (strlen($slug)) { | ||||
$proj_result->setAutocomplete('#'.$slug); | $proj_result->setAutocomplete('#'.$slug); | ||||
} | } | ||||
$proj_result->setImageURI($proj->getProfileImageURI()); | $proj_result->setImageURI($proj->getProfileImageURI()); | ||||
$description = idx($descriptions, $phid); | |||||
if (strlen($description)) { | |||||
$description = PhabricatorMarkupEngine::summarize($description); | |||||
$proj_result->addAttribute($description); | |||||
} | |||||
$results[] = $proj_result; | $results[] = $proj_result; | ||||
} | } | ||||
return $results; | return $results; | ||||
} | } | ||||
} | } |
This comment has a TODO.