Page MenuHomePhabricator

D14773.id.diff
No OneTemporary

D14773.id.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2849,6 +2849,7 @@
'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 @@
'PhabricatorProjectsEditEngineExtension' => 'PhabricatorEditEngineExtension',
'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField',
'PhabricatorProjectsPolicyRule' => 'PhabricatorPolicyRule',
+ 'PhabricatorProjectsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',
'PhabricatorProjectsSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
'PhabricatorProtocolAdapter' => 'Phobject',
'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck',
diff --git a/src/applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php b/src/applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/engineextension/PhabricatorProjectsSearchEngineAttachment.php
@@ -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),
+ );
+ }
+
+}
diff --git a/src/applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php b/src/applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php
--- a/src/applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php
+++ b/src/applications/project/engineextension/PhabricatorProjectsSearchEngineExtension.php
@@ -49,5 +49,12 @@
return $fields;
}
+ public function getSearchAttachments() {
+ return array(
+ id(new PhabricatorProjectsSearchEngineAttachment())
+ ->setAttachmentKey('projects'),
+ );
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 24, 10:07 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7388983
Default Alt Text
D14773.id.diff (3 KB)

Event Timeline