mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Add a "projects" Search attachment for Conduit APIs
Summary: Ref T9964. Builds on D14772. Allows callers to request project PHIDs for objects. Test Plan: {F1025468} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9964 Differential Revision: https://secure.phabricator.com/D14773
This commit is contained in:
parent
2160c45619
commit
c0e20a11c1
3 changed files with 52 additions and 0 deletions
|
@ -2849,6 +2849,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectsEditEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php',
|
||||
'PhabricatorProjectsEditField' => 'applications/transactions/editfield/PhabricatorProjectsEditField.php',
|
||||
'PhabricatorProjectsPolicyRule' => 'applications/project/policyrule/PhabricatorProjectsPolicyRule.php',
|
||||
'PhabricatorProjectsSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php',
|
||||
'PhabricatorProjectsSearchEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php',
|
||||
'PhabricatorProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorProtocolAdapter.php',
|
||||
'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php',
|
||||
|
@ -7128,6 +7129,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectsEditEngineExtension' => 'PhabricatorEditEngineExtension',
|
||||
'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField',
|
||||
'PhabricatorProjectsPolicyRule' => 'PhabricatorPolicyRule',
|
||||
'PhabricatorProjectsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
|
||||
'PhabricatorProjectsSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
||||
'PhabricatorProtocolAdapter' => 'Phobject',
|
||||
'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck',
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectsSearchEngineAttachment
|
||||
extends PhabricatorSearchEngineAttachment {
|
||||
|
||||
public function getAttachmentName() {
|
||||
return pht('Projects');
|
||||
}
|
||||
|
||||
public function getAttachmentDescription() {
|
||||
return pht('Get information about projects.');
|
||||
}
|
||||
|
||||
public function loadAttachmentData(array $objects, $spec) {
|
||||
$object_phids = mpull($objects, 'getPHID');
|
||||
|
||||
$projects_query = id(new PhabricatorEdgeQuery())
|
||||
->withSourcePHIDs($object_phids)
|
||||
->withEdgeTypes(
|
||||
array(
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
|
||||
));
|
||||
$projects_query->execute();
|
||||
|
||||
return array(
|
||||
'projects.query' => $projects_query,
|
||||
);
|
||||
}
|
||||
|
||||
public function getAttachmentForObject($object, $data, $spec) {
|
||||
$projects_query = $data['projects.query'];
|
||||
$object_phid = $object->getPHID();
|
||||
|
||||
$project_phids = $projects_query->getDestinationPHIDs(
|
||||
array($object_phid),
|
||||
array(PhabricatorProjectObjectHasProjectEdgeType::EDGECONST));
|
||||
|
||||
return array(
|
||||
'projectPHIDs' => array_values($project_phids),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -49,5 +49,12 @@ final class PhabricatorProjectsSearchEngineExtension
|
|||
return $fields;
|
||||
}
|
||||
|
||||
public function getSearchAttachments() {
|
||||
return array(
|
||||
id(new PhabricatorProjectsSearchEngineAttachment())
|
||||
->setAttachmentKey('projects'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue